diff --git a/cmake/define.inc b/cmake/define.inc
index 6f49630d5c..e825dce024 100755
--- a/cmake/define.inc
+++ b/cmake/define.inc
@@ -69,7 +69,6 @@ IF (TD_LINUX_32)
ENDIF ()
IF (TD_ARM_64)
- ADD_DEFINITIONS(-D_M_X64)
ADD_DEFINITIONS(-D_TD_ARM_64)
ADD_DEFINITIONS(-D_TD_ARM_)
ADD_DEFINITIONS(-DUSE_LIBICONV)
@@ -86,17 +85,19 @@ IF (TD_ARM_32)
ENDIF ()
IF (TD_MIPS_64)
- ADD_DEFINITIONS(-D_TD_MIPS_64_)
+ ADD_DEFINITIONS(-D_TD_MIPS_)
+ ADD_DEFINITIONS(-D_TD_MIPS_64)
ADD_DEFINITIONS(-DUSE_LIBICONV)
MESSAGE(STATUS "mips64 is defined")
- SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -gdwarf-2 -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
+ SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -fsigned-char -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
ENDIF ()
IF (TD_MIPS_32)
- ADD_DEFINITIONS(-D_TD_MIPS_32_)
+ ADD_DEFINITIONS(-D_TD_MIPS_)
+ ADD_DEFINITIONS(-D_TD_MIPS_32)
ADD_DEFINITIONS(-DUSE_LIBICONV)
MESSAGE(STATUS "mips32 is defined")
- SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -gdwarf-2 -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
+ SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
ENDIF ()
IF (TD_APLHINE)
diff --git a/cmake/install.inc b/cmake/install.inc
index 50dc4162f9..9e325531d5 100755
--- a/cmake/install.inc
+++ b/cmake/install.inc
@@ -32,7 +32,7 @@ ELSEIF (TD_WINDOWS)
#INSTALL(TARGETS taos RUNTIME DESTINATION driver)
#INSTALL(TARGETS shell RUNTIME DESTINATION .)
IF (TD_MVN_INSTALLED)
- INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.27-dist.jar DESTINATION connector/jdbc)
+ INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.28-dist.jar DESTINATION connector/jdbc)
ENDIF ()
ELSEIF (TD_DARWIN)
SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh")
diff --git a/documentation20/cn/11.administrator/docs.md b/documentation20/cn/11.administrator/docs.md
index f8dc794d7d..72fcd05d52 100644
--- a/documentation20/cn/11.administrator/docs.md
+++ b/documentation20/cn/11.administrator/docs.md
@@ -144,7 +144,7 @@ TDengine集群中加入一个新的dnode时,涉及集群相关的一些参数
- numOfMnodes:系统中管理节点个数。默认值:3。
- balance:是否启动负载均衡。0:否,1:是。默认值:1。
- mnodeEqualVnodeNum: 一个mnode等同于vnode消耗的个数。默认值:4。
-- offlineThreshold: dnode离线阈值,超过该时间将导致该dnode从集群中删除。单位为秒,默认值:86400*10(即10天)。
+- offlineThreshold: dnode离线阈值,超过该时间将导致该dnode从集群中删除。单位为秒,默认值:86400*100(即100天)。
- statusInterval: dnode向mnode报告状态时长。单位为秒,默认值:1。
- maxTablesPerVnode: 每个vnode中能够创建的最大表个数。默认值:1000000。
- maxVgroupsPerDb: 每个数据库中能够使用的最大vgroup个数。
diff --git a/documentation20/cn/12.taos-sql/docs.md b/documentation20/cn/12.taos-sql/docs.md
index 2415b7cd01..c754eae088 100644
--- a/documentation20/cn/12.taos-sql/docs.md
+++ b/documentation20/cn/12.taos-sql/docs.md
@@ -48,15 +48,15 @@ TDengine 缺省的时间戳是毫秒精度,但通过修改配置参数 enableM
| 3 | BIGINT | 8 | 长整型,范围 [-2^63+1, 2^63-1], -2^63 用于 NULL |
| 4 | FLOAT | 4 | 浮点型,有效位数 6-7,范围 [-3.4E38, 3.4E38] |
| 5 | DOUBLE | 8 | 双精度浮点型,有效位数 15-16,范围 [-1.7E308, 1.7E308] |
-| 6 | BINARY | 自定义 | 用于记录 ASCII 型字符串。理论上,最长可以有 16374 字节,但由于每行数据最多 16K 字节,实际上限一般小于理论值。 binary 仅支持字符串输入,字符串两端使用单引号引用,否则英文全部自动转化为小写。使用时须指定大小,如 binary(20) 定义了最长为 20 个字符的字符串,每个字符占 1 byte 的存储空间,此时如果用户字符串超出 20 字节将会报错。对于字符串内的单引号,可以用转义字符反斜线加单引号来表示,即 `\’`。 |
+| 6 | BINARY | 自定义 | 记录二进制字节型字符串,建议只用于处理 ASCII 可见字符,中文等多字节字符需使用 nchar。理论上,最长可以有 16374 字节,但由于每行数据最多 16K 字节,实际上限一般小于理论值。binary 仅支持字符串输入,字符串两端使用单引号引用,否则英文全部自动转化为小写。使用时须指定大小,如 binary(20) 定义了最长为 20 个字节型字符的字符串,每个字节型字符占 1 byte 的存储空间,此时如果用户字符串超出 20 字节将会报错。对于字符串内的单引号,可以用转义字符反斜线加单引号来表示,即 `\’`。 |
| 7 | SMALLINT | 2 | 短整型, 范围 [-32767, 32767], -32768 用于 NULL |
| 8 | TINYINT | 1 | 单字节整型,范围 [-127, 127], -128 用于 NULL |
| 9 | BOOL | 1 | 布尔型,{true, false} |
-| 10 | NCHAR | 自定义 | 用于记录非 ASCII 型字符串,如中文字符。每个 nchar 字符占用 4 bytes 的存储空间。字符串两端使用单引号引用,字符串内的单引号需用转义字符 `\’`。nchar 使用时须指定字符串大小,类型为 nchar(10) 的列表示此列的字符串最多存储 10 个 nchar 字符,会固定占用 40 bytes 的空间。如果用户字符串长度超出声明长度,将会报错。 |
+| 10 | NCHAR | 自定义 | 记录包含多字节字符在内的字符串,如中文字符。每个 nchar 字符占用 4 bytes 的存储空间。字符串两端使用单引号引用,字符串内的单引号需用转义字符 `\’`。nchar 使用时须指定字符串大小,类型为 nchar(10) 的列表示此列的字符串最多存储 10 个 nchar 字符,会固定占用 40 bytes 的空间。如果用户字符串长度超出声明长度,将会报错。 |
**Tips**:
1. TDengine 对 SQL 语句中的英文字符不区分大小写,自动转化为小写执行。因此用户大小写敏感的字符串及密码,需要使用单引号将字符串引起来。
-2. 应避免使用 BINARY 类型来保存非 ASCII 型的字符串,会很容易导致数据乱码等错误。正确的做法是使用 NCHAR 类型来保存中文字符。
+2. **注意**,虽然 Binary 类型在底层存储上支持字节型的二进制字符,但不同编程语言对二进制数据的处理方式并不保证一致,因此建议在 Binary 类型中只存储 ASCII 可见字符,而避免存储不可见字符。多字节的数据,例如中文字符,则需要使用 nchar 类型进行保存。如果强行使用 Binary 类型保存中文字符,虽然有时也能正常读写,但并不带有字符集信息,很容易出现数据乱码甚至数据损坏。
## 数据库管理
diff --git a/documentation20/cn/13.faq/docs.md b/documentation20/cn/13.faq/docs.md
index 5a0f890cae..e561f91c94 100644
--- a/documentation20/cn/13.faq/docs.md
+++ b/documentation20/cn/13.faq/docs.md
@@ -102,7 +102,7 @@ TDengine 目前尚不支持删除功能,未来根据用户需求可能会支
批量插入。每条写入语句可以一张表同时插入多条记录,也可以同时插入多张表的多条记录。
-## 12. 最有效的写入数据的方法是什么?windows系统下插入的nchar类数据中的汉字被解析成了乱码如何解决?
+## 12. windows系统下插入的nchar类数据中的汉字被解析成了乱码如何解决?
Windows下插入nchar类的数据中如果有中文,请先确认系统的地区设置成了中国(在Control Panel里可以设置),这时cmd中的`taos`客户端应该已经可以正常工作了;如果是在IDE里开发Java应用,比如Eclipse, Intellij,请确认IDE里的文件编码为GBK(这是Java默认的编码类型),然后在生成Connection时,初始化客户端的配置,具体语句如下:
```JAVA
diff --git a/src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h b/src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h
index 582bd6bac0..b3060e2c82 100644
--- a/src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h
+++ b/src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h
@@ -49,6 +49,14 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setOptions
JNIEXPORT jstring JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getTsCharset
(JNIEnv *, jclass);
+/*
+ * Class: com_taosdata_jdbc_TSDBJNIConnector
+ * Method: getResultTimePrecision
+ * Signature: (J)J
+ */
+JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TDDBJNIConnector_getResultTimePrecision
+ (JNIEnv *, jobject, jlong, jlong);
+
/*
* Class: com_taosdata_jdbc_TSDBJNIConnector
* Method: connectImp
diff --git a/src/client/src/TSDBJNIConnector.c b/src/client/src/TSDBJNIConnector.c
index 56e155311e..7447e36ac9 100644
--- a/src/client/src/TSDBJNIConnector.c
+++ b/src/client/src/TSDBJNIConnector.c
@@ -671,3 +671,20 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_validateCreateTab
JNIEXPORT jstring JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getTsCharset(JNIEnv *env, jobject jobj) {
return (*env)->NewStringUTF(env, (const char *)tsCharset);
}
+
+JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TDDBJNIConnector_getResultTimePrecision(JNIEnv *env, jobject jobj, jlong con,
+ jlong res) {
+ TAOS *tscon = (TAOS *)con;
+ if (tscon == NULL) {
+ jniError("jobj:%p, connection is closed", jobj);
+ return JNI_CONNECTION_NULL;
+ }
+
+ TAOS_RES *result = (TAOS_RES *)res;
+ if (result == NULL) {
+ jniError("jobj:%p, conn:%p, resultset is null", jobj, tscon);
+ return JNI_RESULT_SET_NULL;
+ }
+
+ return taos_result_precision(result);
+}
\ No newline at end of file
diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c
index 5bf7e280af..a17ae913d0 100644
--- a/src/client/src/tscAsync.c
+++ b/src/client/src/tscAsync.c
@@ -57,7 +57,7 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, __async_cb_func_t fp, void* para
strntolower(pSql->sqlstr, sqlstr, (int32_t)sqlLen);
- tscDebugL("%p SQL: %s", pSql, pSql->sqlstr);
+ tscDebugL("0x%"PRIx64" SQL: %s", pSql->self, pSql->sqlstr);
pCmd->curSql = pSql->sqlstr;
int32_t code = tsParseSql(pSql, true);
@@ -283,7 +283,7 @@ void tscQueueAsyncError(void(*fp), void *param, int32_t code) {
static void tscAsyncResultCallback(SSchedMsg *pMsg) {
SSqlObj* pSql = (SSqlObj*)taosAcquireRef(tscObjRef, (int64_t)pMsg->ahandle);
if (pSql == NULL || pSql->signature != pSql) {
- tscDebug("%p SqlObj is freed, not add into queue async res", pSql);
+ tscDebug("%p SqlObj is freed, not add into queue async res", pMsg->ahandle);
return;
}
@@ -372,13 +372,13 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
goto _error;
}
- tscDebug("%p get %s successfully", pSql, msg);
+ tscDebug("0x%"PRIx64" get %s successfully", pSql->self, msg);
if (pSql->pStream == NULL) {
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd, pCmd->clauseIndex);
// check if it is a sub-query of super table query first, if true, enter another routine
if (TSDB_QUERY_HAS_TYPE(pQueryInfo->type, (TSDB_QUERY_TYPE_STABLE_SUBQUERY|TSDB_QUERY_TYPE_SUBQUERY|TSDB_QUERY_TYPE_TAG_FILTER_QUERY))) {
- tscDebug("%p update local table meta, continue to process sql and send the corresponding query", pSql);
+ tscDebug("0x%"PRIx64" update local table meta, continue to process sql and send the corresponding query", pSql->self);
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
@@ -402,7 +402,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
return;
} else { // continue to process normal async query
if (pCmd->parseFinished) {
- tscDebug("%p update local table meta, continue to process sql and send corresponding query", pSql);
+ tscDebug("0x%"PRIx64" update local table meta, continue to process sql and send corresponding query", pSql->self);
STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
code = tscGetTableMeta(pSql, pTableMetaInfo);
@@ -416,7 +416,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
assert(pCmd->command != TSDB_SQL_INSERT);
if (pCmd->command == TSDB_SQL_SELECT) {
- tscDebug("%p redo parse sql string and proceed", pSql);
+ tscDebug("0x%"PRIx64" redo parse sql string and proceed", pSql->self);
pCmd->parseFinished = false;
tscResetSqlCmd(pCmd, true);
@@ -436,7 +436,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
taosReleaseRef(tscObjRef, pSql->self);
return;
} else {
- tscDebug("%p continue parse sql after get table meta", pSql);
+ tscDebug("0x%"PRIx64" continue parse sql after get table meta", pSql->self);
code = tsParseSql(pSql, false);
if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) {
@@ -490,7 +490,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
}
}
- tscDebug("%p stream:%p meta is updated, start new query, command:%d", pSql, pSql->pStream, pSql->cmd.command);
+ tscDebug("0x%"PRIx64" stream:%p meta is updated, start new query, command:%d", pSql->self, pSql->pStream, pSql->cmd.command);
if (!pSql->cmd.parseFinished) {
tsParseSql(pSql, false);
}
diff --git a/src/client/src/tscLocalMerge.c b/src/client/src/tscLocalMerge.c
index f701ca25f3..c7dccb2162 100644
--- a/src/client/src/tscLocalMerge.c
+++ b/src/client/src/tscLocalMerge.c
@@ -129,7 +129,7 @@ void tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrde
for (int32_t i = 0; i < numOfBuffer; ++i) {
int32_t len = pMemBuffer[i]->fileMeta.flushoutData.nLength;
if (len == 0) {
- tscDebug("%p no data retrieved from orderOfVnode:%d", pSql, i + 1);
+ tscDebug("0x%"PRIx64" no data retrieved from orderOfVnode:%d", pSql->self, i + 1);
continue;
}
@@ -139,7 +139,7 @@ void tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrde
if (numOfFlush == 0 || numOfBuffer == 0) {
tscLocalReducerEnvDestroy(pMemBuffer, pDesc, finalmodel, pFFModel, numOfBuffer);
pCmd->command = TSDB_SQL_RETRIEVE_EMPTY_RESULT; // no result, set the result empty
- tscDebug("%p retrieved no data", pSql);
+ tscDebug("0x%"PRIx64" retrieved no data", pSql->self);
return;
}
@@ -171,7 +171,7 @@ void tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrde
pMerger->numOfVnode = numOfBuffer;
pMerger->pDesc = pDesc;
- tscDebug("%p the number of merged leaves is: %d", pSql, pMerger->numOfBuffer);
+ tscDebug("0x%"PRIx64" the number of merged leaves is: %d", pSql->self, pReducer->numOfBuffer);
int32_t idx = 0;
for (int32_t i = 0; i < numOfBuffer; ++i) {
@@ -194,7 +194,7 @@ void tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrde
ds->pageId = 0;
ds->rowIdx = 0;
- tscDebug("%p load data from disk into memory, orderOfVnode:%d, total:%d", pSql, i + 1, idx + 1);
+ tscDebug("0x%"PRIx64" load data from disk into memory, orderOfVnode:%d, total:%d", pSql->self, i + 1, idx + 1);
tExtMemBufferLoadData(pMemBuffer[i], &(ds->filePage), j, 0);
#ifdef _DEBUG_VIEW
printf("load data page into mem for build loser tree: %" PRIu64 " rows\n", ds->filePage.num);
@@ -208,7 +208,7 @@ void tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrde
#endif
if (ds->filePage.num == 0) { // no data in this flush, the index does not increase
- tscDebug("%p flush data is empty, ignore %d flush record", pSql, idx);
+ tscDebug("0x%"PRIx64" flush data is empty, ignore %d flush record", pSql->self, idx);
tfree(ds);
continue;
}
@@ -450,7 +450,7 @@ void tscDestroyLocalMerger(SSqlObj *pSql) {
free(pLocalMerge);
- tscDebug("%p free local reducer finished", pSql);
+ tscDebug("0x%"PRIx64" free local reducer finished", pSql->self);
}
static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCmd, SColumnModel *pModel) {
diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c
index d0dcf9c879..9cfe7909b4 100644
--- a/src/client/src/tscParseInsert.c
+++ b/src/client/src/tscParseInsert.c
@@ -1095,7 +1095,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
str = pCmd->curSql;
}
- tscDebug("%p create data block list hashList:%p", pSql, pCmd->pTableBlockHashList);
+ tscDebug("0x%"PRIx64" create data block list hashList:%p", pSql->self, pCmd->pTableBlockHashList);
while (1) {
int32_t index = 0;
@@ -1309,7 +1309,7 @@ int tsParseSql(SSqlObj *pSql, bool initial) {
SSqlCmd* pCmd = &pSql->cmd;
if ((!pCmd->parseFinished) && (!initial)) {
- tscDebug("%p resume to parse sql: %s", pSql, pCmd->curSql);
+ tscDebug("0x%"PRIx64" resume to parse sql: %s", pSql->self, pCmd->curSql);
}
ret = tscAllocPayload(&pSql->cmd, TSDB_DEFAULT_PAYLOAD_SIZE);
diff --git a/src/client/src/tscProfile.c b/src/client/src/tscProfile.c
index 3222784648..7ffc9bc310 100644
--- a/src/client/src/tscProfile.c
+++ b/src/client/src/tscProfile.c
@@ -61,7 +61,7 @@ void tscAddIntoSqlList(SSqlObj *pSql) {
pSql->stime = taosGetTimestampMs();
pSql->listed = 1;
- tscDebug("%p added into sqlList", pSql);
+ tscDebug("0x%"PRIx64" added into sqlList", pSql->self);
}
void tscSaveSlowQueryFpCb(void *param, TAOS_RES *result, int code) {
@@ -99,7 +99,7 @@ void tscSaveSlowQuery(SSqlObj *pSql) {
return;
}
- tscDebug("%p query time:%" PRId64 " sql:%s", pSql, pSql->res.useconds, pSql->sqlstr);
+ tscDebug("0x%"PRIx64" query time:%" PRId64 " sql:%s", pSql->self, pSql->res.useconds, pSql->sqlstr);
int32_t sqlSize = (int32_t)(TSDB_SLOW_QUERY_SQL_LEN + size);
char *sql = malloc(sqlSize);
@@ -141,7 +141,7 @@ void tscRemoveFromSqlList(SSqlObj *pSql) {
pSql->listed = 0;
tscSaveSlowQuery(pSql);
- tscDebug("%p removed from sqlList", pSql);
+ tscDebug("0x%"PRIx64" removed from sqlList", pSql->self);
}
void tscKillQuery(STscObj *pObj, uint32_t killId) {
@@ -158,7 +158,7 @@ void tscKillQuery(STscObj *pObj, uint32_t killId) {
if (pSql == NULL) {
tscError("failed to kill query, id:%d, it may have completed/terminated", killId);
} else {
- tscDebug("%p query is killed, queryId:%d", pSql, killId);
+ tscDebug("0x%"PRIx64" query is killed, queryId:%d", pSql->self, killId);
taos_stop_query(pSql);
}
}
@@ -213,7 +213,7 @@ void tscKillStream(STscObj *pObj, uint32_t killId) {
pthread_mutex_unlock(&pObj->mutex);
if (pStream) {
- tscDebug("%p stream:%p is killed, streamId:%d", pStream->pSql, pStream, killId);
+ tscDebug("0x%"PRIx64" stream:%p is killed, streamId:%d", pStream->pSql->self, pStream, killId);
if (pStream->callback) {
pStream->callback(pStream->param);
}
@@ -273,7 +273,7 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
pSdesc->num = htobe64(pStream->num);
pSdesc->useconds = htobe64(pStream->useconds);
- pSdesc->stime = htobe64(pStream->stime - pStream->interval.interval);
+ pSdesc->stime = (pStream->stime == INT64_MIN) ? htobe64(pStream->stime) : htobe64(pStream->stime - pStream->interval.interval);
pSdesc->ctime = htobe64(pStream->ctime);
pSdesc->slidingTime = htobe64(pStream->interval.sliding);
diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c
index d3523a361b..2d8f51a0f4 100644
--- a/src/client/src/tscSQLParser.c
+++ b/src/client/src/tscSQLParser.c
@@ -1663,7 +1663,7 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS
}
if (pQueryInfo->fieldsInfo.numOfOutput > TSDB_MAX_COLUMNS) {
- return TSDB_CODE_TSC_INVALID_SQL;
+ return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
}
}
@@ -3086,7 +3086,7 @@ static SColumnFilterInfo* addColumnFilterInfo(SColumnFilterList* filterList) {
return pColFilterInfo;
}
-static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SColumnFilterInfo* pColumnFilter,
+static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, STableMeta* pTableMeta, SColumnFilterInfo* pColumnFilter,
int16_t colType, tSqlExpr* pExpr) {
const char* msg = "not supported filter condition";
@@ -3101,6 +3101,12 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
if (TSDB_CODE_SUCCESS != retVal) {
return retVal;
}
+ } else if ((colType == TSDB_DATA_TYPE_TIMESTAMP) && (TSDB_DATA_TYPE_BIGINT == pRight->value.nType)) {
+ STableComInfo tinfo = tscGetTableInfo(pTableMeta);
+
+ if ((tinfo.precision == TSDB_TIME_PRECISION_MILLI) && (pRight->flags & (1 << EXPR_FLAG_US_TIMESTAMP))) {
+ pRight->value.i64 /= 1000;
+ }
}
int32_t retVal = TSDB_CODE_SUCCESS;
@@ -3926,6 +3932,10 @@ int32_t getQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr
const char* msg1 = "query condition between different columns must use 'AND'";
+ if ((*pExpr)->flags & (1 << EXPR_FLAG_TS_ERROR)) {
+ return TSDB_CODE_TSC_INVALID_SQL;
+ }
+
tSqlExpr* pLeft = (*pExpr)->pLeft;
tSqlExpr* pRight = (*pExpr)->pRight;
@@ -3963,6 +3973,14 @@ int32_t getQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr
exchangeExpr(*pExpr);
+ if (pLeft->tokenId == TK_ID && pRight->tokenId == TK_TIMESTAMP && (pRight->flags & (1 << EXPR_FLAG_TIMESTAMP_VAR))) {
+ return TSDB_CODE_TSC_INVALID_SQL;
+ }
+
+ if ((pLeft->flags & (1 << EXPR_FLAG_TS_ERROR)) || (pRight->flags & (1 << EXPR_FLAG_TS_ERROR))) {
+ return TSDB_CODE_TSC_INVALID_SQL;
+ }
+
return handleExprInQueryCond(pCmd, pQueryInfo, pExpr, pCondExpr, type, parentOptr);
}
@@ -5547,15 +5565,15 @@ int32_t validateLimitNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t clauseI
pQueryInfo->clauseLimit = pQueryInfo->limit.limit;
pQueryInfo->slimit = pSqlNode->slimit;
- tscDebug("%p limit:%" PRId64 ", offset:%" PRId64 " slimit:%" PRId64 ", soffset:%" PRId64, pSql, pQueryInfo->limit.limit,
- pQueryInfo->limit.offset, pQueryInfo->slimit.limit, pQueryInfo->slimit.offset);
+ tscDebug("0x%"PRIx64" limit:%" PRId64 ", offset:%" PRId64 " slimit:%" PRId64 ", soffset:%" PRId64, pSql->self,
+ pQueryInfo->limit.limit, pQueryInfo->limit.offset, pQueryInfo->slimit.limit, pQueryInfo->slimit.offset);
if (pQueryInfo->slimit.offset < 0 || pQueryInfo->limit.offset < 0) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg0);
}
if (pQueryInfo->limit.limit == 0) {
- tscDebug("%p limit 0, no output result", pSql);
+ tscDebug("0x%"PRIx64" limit 0, no output result", pSql->self);
pQueryInfo->command = TSDB_SQL_RETRIEVE_EMPTY_RESULT;
return TSDB_CODE_SUCCESS;
}
@@ -5577,7 +5595,7 @@ int32_t validateLimitNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t clauseI
}
if (pQueryInfo->slimit.limit == 0) {
- tscDebug("%p slimit 0, no output result", pSql);
+ tscDebug("0x%"PRIx64" slimit 0, no output result", pSql->self);
pQueryInfo->command = TSDB_SQL_RETRIEVE_EMPTY_RESULT;
return TSDB_CODE_SUCCESS;
}
@@ -5595,7 +5613,7 @@ int32_t validateLimitNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t clauseI
// No tables included. No results generated. Query results are empty.
if (pTableMetaInfo->vgroupList->numOfVgroups == 0) {
- tscDebug("%p no table in super table, no output result", pSql);
+ tscDebug("0x%"PRIx64" no table in super table, no output result", pSql->self);
pQueryInfo->command = TSDB_SQL_RETRIEVE_EMPTY_RESULT;
return TSDB_CODE_SUCCESS;
}
@@ -6357,7 +6375,7 @@ void tscPrintSelNodeList(SSqlObj* pSql, int32_t subClauseIndex) {
int32_t totalBufSize = 1024;
- char str[1024] = {0};
+ char str[1024+1] = {0};
int32_t offset = 0;
offset += sprintf(str, "num:%d [", size);
@@ -6383,7 +6401,7 @@ void tscPrintSelNodeList(SSqlObj* pSql, int32_t subClauseIndex) {
assert(offset < totalBufSize);
str[offset] = ']';
assert(offset < totalBufSize);
- tscDebug("%p select clause:%s", pSql, str);
+ tscDebug("0x%"PRIx64" select clause:%s", pSql->self, str);
}
int32_t doCheckForCreateTable(SSqlObj* pSql, int32_t subClauseIndex, SSqlInfo* pInfo) {
diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c
index 4156bc7649..931a846cb5 100644
--- a/src/client/src/tscServer.c
+++ b/src/client/src/tscServer.c
@@ -148,7 +148,7 @@ static void tscUpdateVgroupInfo(SSqlObj *pSql, SRpcEpSet *pEpSet) {
// Update the local cached epSet info cached by SqlObj
int32_t inUse = pSql->epSet.inUse;
tscDumpEpSetFromVgroupInfo(&pSql->epSet, &vgroupInfo);
- tscDebug("%p update the epSet in SqlObj, in use before:%d, after:%d", pSql, inUse, pSql->epSet.inUse);
+ tscDebug("0x%"PRIx64" update the epSet in SqlObj, in use before:%d, after:%d", pSql->self, inUse, pSql->epSet.inUse);
}
@@ -246,11 +246,11 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) {
if (pObj->hbrid != 0) {
int32_t waitingDuring = tsShellActivityTimer * 500;
- tscDebug("%p send heartbeat in %dms", pSql, waitingDuring);
+ tscDebug("0x%"PRIx64" send heartbeat in %dms", pSql->self, waitingDuring);
taosTmrReset(tscProcessActivityTimer, waitingDuring, (void *)pObj->rid, tscTmr, &pObj->pTimer);
} else {
- tscDebug("%p start to close tscObj:%p, not send heartbeat again", pSql, pObj);
+ tscDebug("0x%"PRIx64" start to close tscObj:%p, not send heartbeat again", pSql->self, pObj);
}
}
@@ -327,7 +327,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
pSql->rpcRid = -1;
if (pObj->signature != pObj) {
- tscDebug("%p DB connection is closed, cmd:%d pObj:%p signature:%p", pSql, pCmd->command, pObj, pObj->signature);
+ tscDebug("0x%"PRIx64" DB connection is closed, cmd:%d pObj:%p signature:%p", pSql->self, pCmd->command, pObj, pObj->signature);
taosRemoveRef(tscObjRef, handle);
taosReleaseRef(tscObjRef, handle);
@@ -337,8 +337,8 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd, 0);
if (pQueryInfo != NULL && pQueryInfo->type == TSDB_QUERY_TYPE_FREE_RESOURCE) {
- tscDebug("%p sqlObj needs to be released or DB connection is closed, cmd:%d type:%d, pObj:%p signature:%p",
- pSql, pCmd->command, pQueryInfo->type, pObj, pObj->signature);
+ tscDebug("0x%"PRIx64" sqlObj needs to be released or DB connection is closed, cmd:%d type:%d, pObj:%p signature:%p",
+ pSql->self, pCmd->command, pQueryInfo->type, pObj, pObj->signature);
taosRemoveRef(tscObjRef, handle);
taosReleaseRef(tscObjRef, handle);
@@ -397,13 +397,13 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
pRes->rspLen = 0;
if (pRes->code == TSDB_CODE_TSC_QUERY_CANCELLED) {
- tscDebug("%p query is cancelled, code:%s", pSql, tstrerror(pRes->code));
+ tscDebug("0x%"PRIx64" query is cancelled, code:%s", pSql->self, tstrerror(pRes->code));
} else {
pRes->code = rpcMsg->code;
}
if (pRes->code == TSDB_CODE_SUCCESS) {
- tscDebug("%p reset retry counter to be 0 due to success rsp, old:%d", pSql, pSql->retry);
+ tscDebug("0x%"PRIx64" reset retry counter to be 0 due to success rsp, old:%d", pSql->self, pSql->retry);
pSql->retry = 0;
}
@@ -438,10 +438,10 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
pMsg->numOfFailedBlocks = htonl(pMsg->numOfFailedBlocks);
pRes->numOfRows += pMsg->affectedRows;
- tscDebug("%p SQL cmd:%s, code:%s inserted rows:%d rspLen:%d", pSql, sqlCmd[pCmd->command],
+ tscDebug("0x%"PRIx64" SQL cmd:%s, code:%s inserted rows:%d rspLen:%d", pSql->self, sqlCmd[pCmd->command],
tstrerror(pRes->code), pMsg->affectedRows, pRes->rspLen);
} else {
- tscDebug("%p SQL cmd:%s, code:%s rspLen:%d", pSql, sqlCmd[pCmd->command], tstrerror(pRes->code), pRes->rspLen);
+ tscDebug("0x%"PRIx64" SQL cmd:%s, code:%s rspLen:%d", pSql->self, sqlCmd[pCmd->command], tstrerror(pRes->code), pRes->rspLen);
}
}
@@ -460,7 +460,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
if (shouldFree) { // in case of table-meta/vgrouplist query, automatically free it
taosRemoveRef(tscObjRef, handle);
- tscDebug("%p sqlObj is automatically freed", pSql);
+ tscDebug("0x%"PRIx64" sqlObj is automatically freed", pSql->self);
}
taosReleaseRef(tscObjRef, handle);
@@ -523,7 +523,7 @@ int tscProcessSql(SSqlObj *pSql, SQueryInfo* pQueryInfo) {
assert((pQueryInfo->numOfTables == 0 && pQueryInfo->command == TSDB_SQL_HB) || pQueryInfo->numOfTables > 0);
}
- tscDebug("%p SQL cmd:%s will be processed, name:%s, type:%d", pSql, sqlCmd[pCmd->command], name, type);
+ tscDebug("0x%"PRIx64" SQL cmd:%s will be processed, name:%s, type:%d", pSql->self, sqlCmd[pCmd->command], name, type);
if (pCmd->command < TSDB_SQL_MGMT) { // the pTableMetaInfo cannot be NULL
if (pTableMetaInfo == NULL) {
pSql->res.code = TSDB_CODE_TSC_APP_ERROR;
@@ -564,11 +564,12 @@ int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
pRetrieveMsg->header.vgId = htonl(vgId);
- tscDebug("%p build fetch msg from vgId:%d, vgIndex:%d, qId:%" PRIu64, pSql, vgId, vgIndex, pSql->res.qId);
+ tscDebug("0x%"PRIx64" build fetch msg from vgId:%d, vgIndex:%d, qId:0x%" PRIx64, pSql->self, vgId, vgIndex, pSql->res.qId);
} else {
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
pRetrieveMsg->header.vgId = htonl(pTableMeta->vgId);
- tscDebug("%p build fetch msg from only one vgroup, vgId:%d, qId:%" PRIu64, pSql, pTableMeta->vgId, pSql->res.qId);
+ tscDebug("0x%"PRIx64" build fetch msg from only one vgroup, vgId:%d, qId:0x%" PRIx64, pSql->self, pTableMeta->vgId,
+ pSql->res.qId);
}
pSql->cmd.payloadLen = sizeof(SRetrieveTableMsg);
@@ -607,7 +608,7 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
taosHashGetClone(tscVgroupMap, &pTableMeta->vgId, sizeof(pTableMeta->vgId), NULL, &vgroupInfo, sizeof(SNewVgroupInfo));
tscDumpEpSetFromVgroupInfo(&pSql->epSet, &vgroupInfo);
- tscDebug("%p build submit msg, vgId:%d numOfTables:%d numberOfEP:%d", pSql, pTableMeta->vgId, pSql->cmd.numOfTablesInSubmit,
+ tscDebug("0x%"PRIx64" build submit msg, vgId:%d numOfTables:%d numberOfEP:%d", pSql->self, pTableMeta->vgId, pSql->cmd.numOfTablesInSubmit,
pSql->epSet.numOfEps);
return TSDB_CODE_SUCCESS;
}
@@ -673,7 +674,7 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab
vgId = pVgroupInfo->vgId;
tscSetDnodeEpSet(&pSql->epSet, pVgroupInfo);
- tscDebug("%p query on stable, vgIndex:%d, numOfVgroups:%d", pSql, index, pTableMetaInfo->vgroupList->numOfVgroups);
+ tscDebug("0x%"PRIx64" query on stable, vgIndex:%d, numOfVgroups:%d", pSql->self, index, pTableMetaInfo->vgroupList->numOfVgroups);
} else {
vgId = pTableMeta->vgId;
@@ -706,7 +707,7 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab
int32_t numOfTables = (int32_t)taosArrayGetSize(pTableIdList->itemList);
pQueryMsg->numOfTables = htonl(numOfTables); // set the number of tables
- tscDebug("%p query on stable, vgId:%d, numOfTables:%d, vgIndex:%d, numOfVgroups:%d", pSql,
+ tscDebug("0x%"PRIx64" query on stable, vgId:%d, numOfTables:%d, vgIndex:%d, numOfVgroups:%d", pSql->self,
pTableIdList->vgInfo.vgId, numOfTables, index, numOfVgroups);
// serialize each table id info
@@ -724,7 +725,7 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab
char n[TSDB_TABLE_FNAME_LEN] = {0};
tNameExtractFullName(&pTableMetaInfo->name, n);
- tscDebug("%p vgId:%d, query on table:%s, tid:%d, uid:%" PRIu64, pSql, htonl(pQueryMsg->head.vgId), n, pTableMeta->id.tid, pTableMeta->id.uid);
+ tscDebug("0x%"PRIx64" vgId:%d, query on table:%s, tid:%d, uid:%" PRIu64, pSql->self, htonl(pQueryMsg->head.vgId), n, pTableMeta->id.tid, pTableMeta->id.uid);
return pMsg;
}
@@ -1026,7 +1027,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int32_t msgLen = (int32_t)(pMsg - pCmd->payload);
- tscDebug("%p msg built success, len:%d bytes", pSql, msgLen);
+ tscDebug("0x%"PRIx64" msg built success, len:%d bytes", pSql->self, msgLen);
pCmd->payloadLen = msgLen;
pSql->cmd.msgType = TSDB_MSG_TYPE_QUERY;
@@ -1744,7 +1745,7 @@ int tscBuildMultiMeterMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
assert(pCmd->payloadLen + minMsgSize() <= pCmd->allocSize);
- tscDebug("%p build load multi-metermeta msg completed, numOfTables:%d, msg size:%d", pSql, pCmd->count,
+ tscDebug("0x%"PRIx64" build load multi-metermeta msg completed, numOfTables:%d, msg size:%d", pSql->self, pCmd->count,
pCmd->payloadLen);
return pCmd->payloadLen;
@@ -1924,7 +1925,7 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
}
}
- tscDebug("%p recv table meta, uid:%" PRIu64 ", tid:%d, name:%s", pSql, pTableMeta->id.uid, pTableMeta->id.tid,
+ tscDebug("0x%"PRIx64" recv table meta, uid:%" PRIu64 ", tid:%d, name:%s", pSql->self, pTableMeta->id.uid, pTableMeta->id.tid,
tNameGetTableName(&pTableMetaInfo->name));
free(pTableMeta);
@@ -2031,7 +2032,7 @@ int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) {
pSql->res.code = TSDB_CODE_SUCCESS;
pSql->res.numOfTotal = i;
- tscDebug("%p load multi-metermeta resp from complete num:%d", pSql, pSql->res.numOfTotal);
+ tscDebug("0x%"PRIx64" load multi-metermeta resp from complete num:%d", pSql->self, pSql->res.numOfTotal);
#endif
return TSDB_CODE_SUCCESS;
@@ -2200,7 +2201,7 @@ static void createHbObj(STscObj* pObj) {
pSql->signature = pSql;
registerSqlObj(pSql);
- tscDebug("%p HB is allocated, pObj:%p", pSql, pObj);
+ tscDebug("0x%"PRIx64" HB is allocated, pObj:%p", pSql->self, pObj);
pObj->hbrid = pSql->self;
}
@@ -2226,7 +2227,7 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
tscUpdateMgmtEpSet(pSql, &pConnect->epSet);
for (int i = 0; i < pConnect->epSet.numOfEps; ++i) {
- tscDebug("%p epSet.fqdn[%d]: %s, pObj:%p", pSql, i, pConnect->epSet.fqdn[i], pObj);
+ tscDebug("0x%"PRIx64" epSet.fqdn[%d]: %s, pObj:%p", pSql->self, i, pConnect->epSet.fqdn[i], pObj);
}
}
@@ -2270,7 +2271,7 @@ int tscProcessDropTableRsp(SSqlObj *pSql) {
tNameExtractFullName(&pTableMetaInfo->name, name);
taosHashRemove(tscTableMetaInfo, name, strnlen(name, TSDB_TABLE_FNAME_LEN));
- tscDebug("%p remove table meta after drop table:%s, numOfRemain:%d", pSql, name, (int32_t) taosHashGetSize(tscTableMetaInfo));
+ tscDebug("0x%"PRIx64" remove table meta after drop table:%s, numOfRemain:%d", pSql->self, name, (int32_t) taosHashGetSize(tscTableMetaInfo));
tfree(pTableMetaInfo->pTableMeta);
return 0;
@@ -2282,7 +2283,7 @@ int tscProcessAlterTableMsgRsp(SSqlObj *pSql) {
char name[TSDB_TABLE_FNAME_LEN] = {0};
tNameExtractFullName(&pTableMetaInfo->name, name);
- tscDebug("%p remove tableMeta in hashMap after alter-table: %s", pSql, name);
+ tscDebug("0x%"PRIx64" remove tableMeta in hashMap after alter-table: %s", pSql->self, name);
bool isSuperTable = UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo);
taosHashRemove(tscTableMetaInfo, name, strnlen(name, TSDB_TABLE_FNAME_LEN));
@@ -2314,7 +2315,7 @@ int tscProcessQueryRsp(SSqlObj *pSql) {
pRes->data = NULL;
tscResetForNextRetrieve(pRes);
- tscDebug("%p query rsp received, qId:%"PRIu64, pSql, pRes->qId);
+ tscDebug("0x%"PRIx64" query rsp received, qId:0x%"PRIx64, pSql->self, pRes->qId);
return 0;
}
@@ -2374,7 +2375,7 @@ int tscProcessRetrieveRspFromNode(SSqlObj *pSql) {
}
pRes->row = 0;
- tscDebug("%p numOfRows:%d, offset:%" PRId64 ", complete:%d, qId:%"PRIu64, pSql, pRes->numOfRows, pRes->offset,
+ tscDebug("0x%"PRIx64" numOfRows:%d, offset:%" PRId64 ", complete:%d, qId:0x%"PRIx64, pSql->self, pRes->numOfRows, pRes->offset,
pRes->completed, pRes->qId);
return 0;
@@ -2418,14 +2419,14 @@ static int32_t getTableMetaFromMnode(SSqlObj *pSql, STableMetaInfo *pTableMetaIn
}
}
- tscDebug("%p new pSqlObj:%p to get tableMeta, auto create:%d", pSql, pNew, pNew->cmd.autoCreated);
-
registerSqlObj(pNew);
+ tscDebug("0x%"PRIx64" new pSqlObj:0x%"PRIx64" to get tableMeta, auto create:%d", pSql->self, pNew->self,
+ pNew->cmd.autoCreated);
pNew->fp = tscTableMetaCallBack;
pNew->param = (void *)pSql->self;
- tscDebug("%p metaRid from %" PRId64 " to %" PRId64 , pSql, pSql->metaRid, pNew->self);
+ tscDebug("0x%"PRIx64" metaRid from %" PRId64 " to %" PRId64 , pSql->self, pSql->metaRid, pNew->self);
pSql->metaRid = pNew->self;
@@ -2496,7 +2497,7 @@ int tscRenewTableMeta(SSqlObj *pSql, int32_t tableIndex) {
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
if (pTableMeta) {
- tscDebug("%p update table meta:%s, old meta numOfTags:%d, numOfCols:%d, uid:%" PRId64, pSql, name,
+ tscDebug("0x%"PRIx64" update table meta:%s, old meta numOfTags:%d, numOfCols:%d, uid:%" PRId64, pSql->self, name,
tscGetNumOfTags(pTableMeta), tscGetNumOfColumns(pTableMeta), pTableMeta->id.uid);
}
@@ -2556,12 +2557,12 @@ int tscGetSTableVgroupInfo(SSqlObj *pSql, int32_t clauseIndex) {
pNewQueryInfo->numOfTables = pQueryInfo->numOfTables;
registerSqlObj(pNew);
- tscDebug("%p svgroupRid from %" PRId64 " to %" PRId64 , pSql, pSql->svgroupRid, pNew->self);
+ tscDebug("0x%"PRIx64" svgroupRid from %" PRId64 " to %" PRId64 , pSql->self, pSql->svgroupRid, pNew->self);
pSql->svgroupRid = pNew->self;
- tscDebug("%p new sqlObj:%p to get vgroupInfo, numOfTables:%d", pSql, pNew, pNewQueryInfo->numOfTables);
+ tscDebug("0x%"PRIx64" new sqlObj:%p to get vgroupInfo, numOfTables:%d", pSql->self, pNew, pNewQueryInfo->numOfTables);
pNew->fp = tscTableMetaCallBack;
pNew->param = (void *)pSql->self;
diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c
index 8628350355..2c960ecefd 100644
--- a/src/client/src/tscSql.c
+++ b/src/client/src/tscSql.c
@@ -292,7 +292,7 @@ void taos_close(TAOS *taos) {
pHb->rpcRid = -1;
}
- tscDebug("%p HB is freed", pHb);
+ tscDebug("0x%"PRIx64" HB is freed", pHb->self);
taosReleaseRef(tscObjRef, pHb->self);
#ifdef __APPLE__
// to satisfy later tsem_destroy in taos_free_result
@@ -576,7 +576,7 @@ static bool tscKillQueryInDnode(SSqlObj* pSql) {
cmd == TSDB_SQL_FETCH)) {
pQueryInfo->type = TSDB_QUERY_TYPE_FREE_RESOURCE;
pCmd->command = (pCmd->command > TSDB_SQL_MGMT) ? TSDB_SQL_RETRIEVE : TSDB_SQL_FETCH;
- tscDebug("%p send msg to dnode to free qhandle ASAP before free sqlObj, command:%s", pSql, sqlCmd[pCmd->command]);
+ tscDebug("0x%"PRIx64" send msg to dnode to free qhandle ASAP before free sqlObj, command:%s", pSql->self, sqlCmd[pCmd->command]);
tscProcessSql(pSql, NULL);
return false;
@@ -594,7 +594,7 @@ void taos_free_result(TAOS_RES *res) {
bool freeNow = tscKillQueryInDnode(pSql);
if (freeNow) {
- tscDebug("%p free sqlObj in cache", pSql);
+ tscDebug("0x%"PRIx64" free sqlObj in cache", pSql->self);
taosReleaseRef(tscObjRef, pSql->self);
}
}
@@ -708,7 +708,7 @@ static void tscKillSTableQuery(SSqlObj *pSql) {
tscUnlockByThread(&pSql->squeryLock);
- tscDebug("%p super table query cancelled", pSql);
+ tscDebug("0x%"PRIx64" super table query cancelled", pSql->self);
}
void taos_stop_query(TAOS_RES *res) {
@@ -717,7 +717,7 @@ void taos_stop_query(TAOS_RES *res) {
return;
}
- tscDebug("%p start to cancel query", res);
+ tscDebug("0x%"PRIx64" start to cancel query", pSql->self);
SSqlCmd *pCmd = &pSql->cmd;
// set the error code for master pSqlObj firstly
@@ -744,7 +744,7 @@ void taos_stop_query(TAOS_RES *res) {
}
}
- tscDebug("%p query is cancelled", res);
+ tscDebug("0x%"PRIx64" query is cancelled", pSql->self);
}
bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col) {
@@ -877,7 +877,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) {
pRes->numOfClauseTotal = 0;
- tscDebug("%p Valid SQL: %s pObj:%p", pSql, sql, pObj);
+ tscDebug("0x%"PRIx64" Valid SQL: %s pObj:%p", pSql->self, sql, pObj);
int32_t sqlLen = (int32_t)strlen(sql);
if (sqlLen > tsMaxSQLStringLen) {
@@ -889,7 +889,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) {
pSql->sqlstr = realloc(pSql->sqlstr, sqlLen + 1);
if (pSql->sqlstr == NULL) {
tscError("%p failed to malloc sql string buffer", pSql);
- tscDebug("%p Valid SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(pSql), pObj);
+ tscDebug("0x%"PRIx64" Valid SQL result:%d, %s pObj:%p", pSql->self, pRes->code, taos_errstr(pSql), pObj);
tfree(pSql);
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
@@ -914,7 +914,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) {
}
if (code != TSDB_CODE_SUCCESS) {
- tscDebug("%p Valid SQL result:%d, %s pObj:%p", pSql, code, taos_errstr(pSql), pObj);
+ tscDebug("0x%"PRIx64" Valid SQL result:%d, %s pObj:%p", pSql->self, code, taos_errstr(pSql), pObj);
}
taos_free_result(pSql);
@@ -1027,7 +1027,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
pRes->numOfClauseTotal = 0;
assert(pSql->fp == NULL);
- tscDebug("%p tableNameList: %s pObj:%p", pSql, tableNameList, pObj);
+ tscDebug("0x%"PRIx64" tableNameList: %s pObj:%p", pSql->self, tableNameList, pObj);
int32_t tblListLen = (int32_t)strlen(tableNameList);
if (tblListLen > MAX_TABLE_NAME_LENGTH) {
@@ -1061,7 +1061,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
tscDoQuery(pSql);
- tscDebug("%p load multi table meta result:%d %s pObj:%p", pSql, pRes->code, taos_errstr(pSql), pObj);
+ tscDebug("0x%"PRIx64" load multi table meta result:%d %s pObj:%p", pSql->self, pRes->code, taos_errstr(pSql), pObj);
if ((code = pRes->code) != TSDB_CODE_SUCCESS) {
tscFreeSqlObj(pSql);
}
diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c
index 41d2e89838..2fc857e4c7 100644
--- a/src/client/src/tscStream.c
+++ b/src/client/src/tscStream.c
@@ -70,7 +70,7 @@ static void setRetryInfo(SSqlStream* pStream, int32_t code) {
pSql->res.code = code;
int64_t retryDelayTime = tscGetRetryDelayTime(pStream, pStream->interval.sliding, pStream->precision);
- tscDebug("%p stream:%p, get table Meta failed, retry in %" PRId64 "ms", pSql, pStream, retryDelayTime);
+ tscDebug("0x%"PRIx64" stream:%p, get table Meta failed, retry in %" PRId64 "ms", pSql->self, pStream, retryDelayTime);
tscSetRetryTimer(pStream, pSql, retryDelayTime);
}
@@ -101,10 +101,18 @@ static void doLaunchQuery(void* param, TAOS_RES* tres, int32_t code) {
return;
}
+ if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo) && (pTableMetaInfo->pVgroupTables == NULL) && (pTableMetaInfo->vgroupList == NULL || pTableMetaInfo->vgroupList->numOfVgroups <= 0)) {
+ tscDebug("%p empty vgroup list", pSql);
+ pTableMetaInfo->vgroupList = tscVgroupInfoClear(pTableMetaInfo->vgroupList);
+ code = TSDB_CODE_TSC_APP_ERROR;
+ }
+
// failed to get table Meta or vgroup list, retry in 10sec.
if (code == TSDB_CODE_SUCCESS) {
tscTansformFuncForSTableQuery(pQueryInfo);
- tscDebug("%p stream:%p, start stream query on:%s", pSql, pStream, tNameGetTableName(&pTableMetaInfo->name));
+ tscDebug("0x%"PRIx64" stream:%p, start stream query on:%s", pSql->self, pStream, tNameGetTableName(&pTableMetaInfo->name));
+
+ pQueryInfo->command = TSDB_SQL_SELECT;
pSql->fp = tscProcessStreamQueryCallback;
pSql->fetchFp = tscProcessStreamQueryCallback;
@@ -131,7 +139,7 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) {
pStream->numOfRes = 0; // reset the numOfRes.
SSqlObj *pSql = pStream->pSql;
SQueryInfo* pQueryInfo = tscGetQueryInfo(&pSql->cmd, 0);
- tscDebug("%p add into timer", pSql);
+ tscDebug("0x%"PRIx64" add into timer", pSql->self);
if (pStream->isProject) {
/*
@@ -237,7 +245,7 @@ static void tscStreamFillTimeGap(SSqlStream* pStream, TSKEY ts) {
}
if (rowNum > 0) {
- tscDebug("%p stream:%p %d rows padded", pSql, pStream, rowNum);
+ tscDebug("0x%"PRIx64" stream:%p %d rows padded", pSql, pStream, rowNum);
}
pRes->numOfRows = 0;
@@ -263,7 +271,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
for(int32_t i = 0; i < numOfRows; ++i) {
TAOS_ROW row = taos_fetch_row(res);
if (row != NULL) {
- tscDebug("%p stream:%p fetch result", pSql, pStream);
+ tscDebug("0x%"PRIx64" stream:%p fetch result", pSql->self, pStream);
tscStreamFillTimeGap(pStream, *(TSKEY*)row[0]);
pStream->stime = *(TSKEY *)row[0];
// user callback function
@@ -293,7 +301,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
pStream->stime += 1;
}
- tscDebug("%p stream:%p, query on:%s, fetch result completed, fetched rows:%" PRId64, pSql, pStream, tNameGetTableName(&pTableMetaInfo->name),
+ tscDebug("0x%"PRIx64" stream:%p, query on:%s, fetch result completed, fetched rows:%" PRId64, pSql->self, pStream, tNameGetTableName(&pTableMetaInfo->name),
pStream->numOfRes);
tfree(pTableMetaInfo->pTableMeta);
@@ -318,8 +326,8 @@ static void tscSetRetryTimer(SSqlStream *pStream, SSqlObj *pSql, int64_t timer)
/*
* current time window will be closed, since it too early to exceed the maxRetentWindow value
*/
- tscDebug("%p stream:%p, etime:%" PRId64 " is too old, exceeds the max retention time window:%" PRId64 ", stop the stream",
- pStream->pSql, pStream, pStream->stime, pStream->etime);
+ tscDebug("0x%"PRIx64" stream:%p, etime:%" PRId64 " is too old, exceeds the max retention time window:%" PRId64 ", stop the stream",
+ pStream->pSql->self, pStream, pStream->stime, pStream->etime);
// TODO : How to terminate stream here
if (pStream->callback) {
// Callback function from upper level
@@ -329,10 +337,10 @@ static void tscSetRetryTimer(SSqlStream *pStream, SSqlObj *pSql, int64_t timer)
return;
}
- tscDebug("%p stream:%p, next start at %" PRId64 ", in %" PRId64 "ms. delay:%" PRId64 "ms qrange %" PRId64 "-%" PRId64, pStream->pSql, pStream,
+ tscDebug("0x%"PRIx64" stream:%p, next start at %" PRId64 ", in %" PRId64 "ms. delay:%" PRId64 "ms qrange %" PRId64 "-%" PRId64, pStream->pSql->self, pStream,
now + timer, timer, delay, pStream->stime, etime);
} else {
- tscDebug("%p stream:%p, next start at %" PRId64 ", in %" PRId64 "ms. delay:%" PRId64 "ms qrange %" PRId64 "-%" PRId64, pStream->pSql, pStream,
+ tscDebug("0x%"PRIx64" stream:%p, next start at %" PRId64 ", in %" PRId64 "ms. delay:%" PRId64 "ms qrange %" PRId64 "-%" PRId64, pStream->pSql->self, pStream,
pStream->stime, timer, delay, pStream->stime - pStream->interval.interval, pStream->stime - 1);
}
@@ -378,8 +386,8 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) {
*/
timer = pStream->interval.sliding;
if (pStream->stime > pStream->etime) {
- tscDebug("%p stream:%p, stime:%" PRId64 " is larger than end time: %" PRId64 ", stop the stream", pStream->pSql, pStream,
- pStream->stime, pStream->etime);
+ tscDebug("0x%"PRIx64" stream:%p, stime:%" PRId64 " is larger than end time: %" PRId64 ", stop the stream",
+ pStream->pSql->self, pStream, pStream->stime, pStream->etime);
// TODO : How to terminate stream here
if (pStream->callback) {
// Callback function from upper level
@@ -392,7 +400,7 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) {
int64_t stime = taosTimeTruncate(pStream->stime - 1, &pStream->interval, pStream->precision);
//int64_t stime = taosGetIntervalStartTimestamp(pStream->stime - 1, pStream->interval.interval, pStream->interval.interval, pStream->interval.intervalUnit, pStream->precision);
if (stime >= pStream->etime) {
- tscDebug("%p stream:%p, stime:%" PRId64 " is larger than end time: %" PRId64 ", stop the stream", pStream->pSql, pStream,
+ tscDebug("0x%"PRIx64" stream:%p, stime:%" PRId64 " is larger than end time: %" PRId64 ", stop the stream", pStream->pSql->self, pStream,
pStream->stime, pStream->etime);
// TODO : How to terminate stream here
if (pStream->callback) {
@@ -402,10 +410,12 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) {
taos_close_stream(pStream);
return;
}
-
- timer = pStream->stime - taosGetTimestamp(pStream->precision);
- if (timer < 0) {
- timer = 0;
+
+ if (pStream->stime > 0) {
+ timer = pStream->stime - taosGetTimestamp(pStream->precision);
+ if (timer < 0) {
+ timer = 0;
+ }
}
}
@@ -479,17 +489,20 @@ static int64_t tscGetStreamStartTimestamp(SSqlObj *pSql, SSqlStream *pStream, in
pStream->interval.interval = tsProjectExecInterval;
pStream->interval.sliding = tsProjectExecInterval;
- if (stime != 0) { // first projection start from the latest event timestamp
+ if (stime != INT64_MIN) { // first projection start from the latest event timestamp
assert(stime >= pQueryInfo->window.skey);
stime += 1; // exclude the last records from table
} else {
stime = pQueryInfo->window.skey;
}
} else { // timewindow based aggregation stream
- if (stime == 0) { // no data in meter till now
+ if (stime == INT64_MIN) { // no data in meter till now
if (pQueryInfo->window.skey != INT64_MIN) {
stime = pQueryInfo->window.skey;
+ } else {
+ return stime;
}
+
stime = taosTimeTruncate(stime, &pStream->interval, pStream->precision);
} else {
int64_t newStime = taosTimeTruncate(stime, &pStream->interval, pStream->precision);
@@ -558,7 +571,7 @@ static void tscCreateStream(void *param, TAOS_RES *res, int code) {
taosTmrReset(tscProcessStreamTimer, (int32_t)starttime, pStream, tscTmr, &pStream->pTimer);
- tscDebug("%p stream:%p is opened, query on:%s, interval:%" PRId64 ", sliding:%" PRId64 ", first launched in:%" PRId64 ", sql:%s", pSql,
+ tscDebug("0x%"PRIx64" stream:%p is opened, query on:%s, interval:%" PRId64 ", sliding:%" PRId64 ", first launched in:%" PRId64 ", sql:%s", pSql->self,
pStream, tNameGetTableName(&pTableMetaInfo->name), pStream->interval.interval, pStream->interval.sliding, starttime, pSql->sqlstr);
}
@@ -619,7 +632,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
if (code == TSDB_CODE_SUCCESS) {
tscCreateStream(pStream, pSql, code);
} else if (code != TSDB_CODE_TSC_ACTION_IN_PROGRESS) {
- tscError("%p open stream failed, sql:%s, code:%s", pSql, sqlstr, tstrerror(pRes->code));
+ tscError("%p open stream failed, sql:%s, code:%s", pSql, sqlstr, tstrerror(code));
taosReleaseRef(tscObjRef, pSql->self);
free(pStream);
return NULL;
@@ -645,7 +658,7 @@ void taos_close_stream(TAOS_STREAM *handle) {
taosTmrStopA(&(pStream->pTimer));
- tscDebug("%p stream:%p is closed", pSql, pStream);
+ tscDebug("0x%"PRIx64" stream:%p is closed", pSql->self, pStream);
// notify CQ to release the pStream object
pStream->fp(pStream->param, NULL, NULL);
pStream->pSql = NULL;
diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c
index 41f2a54892..6dee36f073 100644
--- a/src/client/src/tscSubquery.c
+++ b/src/client/src/tscSubquery.c
@@ -82,14 +82,14 @@ static bool allSubqueryDone(SSqlObj *pParentSql) {
SSubqueryState *subState = &pParentSql->subState;
//lock in caller
- tscDebug("%p total subqueries: %d", pParentSql, subState->numOfSub);
+ tscDebug("0x%"PRIx64" total subqueries: %d", pParentSql->self, subState->numOfSub);
for (int i = 0; i < subState->numOfSub; i++) {
if (0 == subState->states[i]) {
- tscDebug("%p subquery:%p, index: %d NOT finished, abort query completion check", pParentSql, pParentSql->pSubs[i], i);
+ tscDebug("0x%"PRIx64" subquery:%p, index: %d NOT finished, abort query completion check", pParentSql->self, pParentSql->pSubs[i], i);
done = false;
break;
} else {
- tscDebug("%p subquery:%p, index: %d finished", pParentSql, pParentSql->pSubs[i], i);
+ tscDebug("0x%"PRIx64" subquery:%p, index: %d finished", pParentSql->self, pParentSql->pSubs[i], i);
}
}
@@ -106,14 +106,14 @@ static bool subAndCheckDone(SSqlObj *pSql, SSqlObj *pParentSql, int idx) {
bool done = allSubqueryDone(pParentSql);
if (done) {
- tscDebug("%p subquery:%p,%d all subs already done", pParentSql, pSql, idx);
+ tscDebug("0x%"PRIx64" subquery:%p,%d all subs already done", pParentSql->self, pSql, idx);
pthread_mutex_unlock(&subState->mutex);
return false;
}
- tscDebug("%p subquery:%p,%d state set to 1", pParentSql, pSql, idx);
+ tscDebug("0x%"PRIx64" subquery:%p,%d state set to 1", pParentSql->self, pSql, idx);
subState->states[idx] = 1;
@@ -159,18 +159,18 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, STimeWindow * win) {
SJoinSupporter* pSupporter = pSql->pSubs[i]->param;
if (pSupporter->pTSBuf == NULL) {
- tscDebug("%p at least one ts-comp is empty, 0 for secondary query after ts blocks intersecting", pSql);
+ tscDebug("0x%"PRIx64" at least one ts-comp is empty, 0 for secondary query after ts blocks intersecting", pSql->self);
return 0;
}
tsBufResetPos(pSupporter->pTSBuf);
if (!tsBufNextPos(pSupporter->pTSBuf)) {
- tscDebug("%p input1 is empty, 0 for secondary query after ts blocks intersecting", pSql);
+ tscDebug("0x%"PRIx64" input1 is empty, 0 for secondary query after ts blocks intersecting", pSql->self);
return 0;
}
- tscDebug("%p sub:%p table idx:%d, input group number:%d", pSql, pSql->pSubs[i], i, pSupporter->pTSBuf->numOfGroups);
+ tscDebug("0x%"PRIx64" sub:%p table idx:%d, input group number:%d", pSql->self, pSql->pSubs[i], i, pSupporter->pTSBuf->numOfGroups);
ctxlist[i].p = pSupporter;
ctxlist[i].res = output;
@@ -376,9 +376,9 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, STimeWindow * win) {
TSKEY et = taosGetTimestampUs();
for (int32_t i = 0; i < joinNum; ++i) {
- tscDebug("%p sub:%p tblidx:%d, input:%" PRId64 ", final:%" PRId64 " in %d vnodes for secondary query after ts blocks "
+ tscDebug("0x%"PRIx64" sub:%p tblidx:%d, input:%" PRId64 ", final:%" PRId64 " in %d vnodes for secondary query after ts blocks "
"intersecting, skey:%" PRId64 ", ekey:%" PRId64 ", numOfVnode:%d, elapsed time:%" PRId64 " us",
- pSql, pSql->pSubs[i], i, ctxlist[i].numOfInput, ctxlist[i].res->numOfTotal, ctxlist[i].res->numOfGroups, win->skey, win->ekey,
+ pSql->self, pSql->pSubs[i], i, ctxlist[i].numOfInput, ctxlist[i].res->numOfTotal, ctxlist[i].res->numOfGroups, win->skey, win->ekey,
tsBufGetNumOfGroup(ctxlist[i].res), et - st);
}
@@ -531,7 +531,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
assert(numOfSub > 0);
// scan all subquery, if one sub query has only ts, ignore it
- tscDebug("%p start to launch secondary subqueries, %d out of %d needs to query", pSql, numOfSub, pSql->subState.numOfSub);
+ tscDebug("0x%"PRIx64" start to launch secondary subqueries, %d out of %d needs to query", pSql->self, numOfSub, pSql->subState.numOfSub);
bool success = true;
@@ -542,7 +542,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
pSupporter = pPrevSub->param;
if (taosArrayGetSize(pSupporter->exprList) == 0) {
- tscDebug("%p subIndex: %d, no need to launch query, ignore it", pSql, i);
+ tscDebug("0x%"PRIx64" subIndex: %d, no need to launch query, ignore it", pSql->self, i);
tscDestroyJoinSupporter(pSupporter);
taos_free_result(pPrevSub);
@@ -565,7 +565,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
success = false;
break;
}
-
+
tscClearSubqueryInfo(&pNew->cmd);
pSql->pSubs[i] = pNew;
@@ -647,8 +647,8 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
subquerySetState(pPrevSub, &pSql->subState, i, 0);
size_t numOfCols = taosArrayGetSize(pQueryInfo->colList);
- tscDebug("%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%" PRIzu ", colList:%" PRIzu ", fieldsInfo:%d, name:%s",
- pSql, pNew, 0, pTableMetaInfo->vgroupIndex, pQueryInfo->type, taosArrayGetSize(pQueryInfo->exprList),
+ tscDebug("0x%"PRIx64" subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%" PRIzu ", colList:%" PRIzu ", fieldsInfo:%d, name:%s",
+ pSql->self, pNew, 0, pTableMetaInfo->vgroupIndex, pQueryInfo->type, taosArrayGetSize(pQueryInfo->exprList),
numOfCols, pQueryInfo->fieldsInfo.numOfOutput, tNameGetTableName(&pTableMetaInfo->name));
}
@@ -776,7 +776,7 @@ void tscBuildVgroupTableInfo(SSqlObj* pSql, STableMetaInfo* pTableMetaInfo, SArr
if (taosArrayGetSize(result) > 0) {
SVgroupTableInfo* prevGroup = taosArrayGet(result, taosArrayGetSize(result) - 1);
- tscDebug("%p vgId:%d, tables:%"PRIzu, pSql, prevGroup->vgInfo.vgId, taosArrayGetSize(prevGroup->itemList));
+ tscDebug("0x%"PRIx64" vgId:%d, tables:%"PRIzu, pSql->self, prevGroup->vgInfo.vgId, taosArrayGetSize(prevGroup->itemList));
}
taosArrayPush(result, &info);
@@ -798,7 +798,7 @@ void tscBuildVgroupTableInfo(SSqlObj* pSql, STableMetaInfo* pTableMetaInfo, SArr
pTableMetaInfo->pVgroupTables = result;
SVgroupTableInfo* g = taosArrayGet(result, taosArrayGetSize(result) - 1);
- tscDebug("%p vgId:%d, tables:%"PRIzu, pSql, g->vgInfo.vgId, taosArrayGetSize(g->itemList));
+ tscDebug("0x%"PRIx64" vgId:%d, tables:%"PRIzu, pSql->self, g->vgInfo.vgId, taosArrayGetSize(g->itemList));
}
}
@@ -888,8 +888,8 @@ static int32_t getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pPar
int32_t size = p0->tagSize - sizeof(int16_t);
SSchema* pColSchema = tscGetColumnSchemaById(pTableMetaInfo->pTableMeta, tagColId);
-
- tscDebug("%p all subquery retrieve complete, do tags match", pParentSql);
+
+ tscDebug("0x%"PRIx64" all subquery retrieve complete, do tags match", pParentSql->self);
for (int32_t i = 0; i < joinNum; i++) {
SJoinSupporter* p = pParentSql->pSubs[i]->param;
@@ -989,8 +989,8 @@ static int32_t getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pPar
tableMIdx = taosArrayGet(tagCond, slot);
continue;
}
-
- tscDebug("%p tag matched, vgId:%d, val:%d, tid:%d, uid:%"PRIu64", tid:%d, uid:%"PRIu64, pParentSql, prev->vgId,
+
+ tscDebug("0x%"PRIx64" tag matched, vgId:%d, val:%d, tid:%d, uid:%"PRIu64", tid:%d, uid:%"PRIu64, pParentSql->self, prev->vgId,
*(int*) prev->tag, prev->tid, prev->uid, cur->tid, cur->uid);
assert(stackidx == tableNum);
@@ -1065,7 +1065,7 @@ static int32_t getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pPar
taosArrayPush(resList, &ctxlist[i].res);
- tscDebug("%p tags match complete, result num: %"PRIzu, pParentSql, num);
+ tscDebug("0x%"PRIx64" tags match complete, result num: %"PRIzu, pParentSql->self, num);
}
return TSDB_CODE_SUCCESS;
@@ -1169,8 +1169,8 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
pTableMetaInfo->vgroupIndex += 1;
assert(pTableMetaInfo->vgroupIndex < totalVgroups);
- tscDebug("%p tid_tag from vgroup index:%d completed, try next vgroup:%d. total vgroups:%d. current numOfRes:%d",
- pSql, pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups, pSupporter->num);
+ tscDebug("0x%"PRIx64" tid_tag from vgroup index:%d completed, try next vgroup:%d. total vgroups:%d. current numOfRes:%d",
+ pSql->self, pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups, pSupporter->num);
pCmd->command = TSDB_SQL_SELECT;
tscResetForNextRetrieve(&pSql->res);
@@ -1184,7 +1184,7 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
// no data exists in next vnode, mark the query completed
// only when there is no subquery exits any more, proceeds to get the intersect of the tuple sets.
if (!subAndCheckDone(pSql, pParentSql, pSupporter->subqueryIndex)) {
- tscDebug("%p tagRetrieve:%p,%d completed, total:%d", pParentSql, tres, pSupporter->subqueryIndex, pParentSql->subState.numOfSub);
+ tscDebug("0x%"PRIx64" tagRetrieve:%p,%d completed, total:%d", pParentSql->self, tres, pSupporter->subqueryIndex, pParentSql->subState.numOfSub);
return;
}
@@ -1203,7 +1203,8 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
if (emptyTagList(resList, pParentSql->subState.numOfSub)) { // no results,return.
assert(pParentSql->fp != tscJoinQueryCallback);
- tscDebug("%p tag intersect does not generated qualified tables for join, free all sub SqlObj and quit", pParentSql);
+ tscDebug("0x%"PRIx64" tag intersect does not generated qualified tables for join, free all sub SqlObj and quit",
+ pParentSql->self);
freeJoinSubqueryObj(pParentSql);
// set no result command
@@ -1225,8 +1226,8 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
((SJoinSupporter*)psub->param)->pVgroupTables = tscVgroupTableInfoDup(pTableMetaInfo->pVgroupTables);
memset(pParentSql->subState.states, 0, sizeof(pParentSql->subState.states[0]) * pParentSql->subState.numOfSub);
- tscDebug("%p reset all sub states to 0", pParentSql);
-
+ tscDebug("0x%"PRIx64" reset all sub states to 0", pParentSql->self);
+
issueTsCompQuery(psub, psub->param, pParentSql);
}
}
@@ -1318,7 +1319,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
}
if (pSupporter->pTSBuf == NULL) {
- tscDebug("%p create tmp file for ts block:%s, size:%d bytes", pSql, pBuf->path, numOfRows);
+ tscDebug("0x%"PRIx64" create tmp file for ts block:%s, size:%d bytes", pSql->self, pBuf->path, numOfRows);
pSupporter->pTSBuf = pBuf;
} else {
assert(pQueryInfo->numOfTables == 1); // for subquery, only one
@@ -1344,8 +1345,8 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
pTableMetaInfo->vgroupIndex += 1;
assert(pTableMetaInfo->vgroupIndex < totalVgroups);
- tscDebug("%p results from vgroup index:%d completed, try next vgroup:%d. total vgroups:%d. current numOfRes:%" PRId64,
- pSql, pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups,
+ tscDebug("0x%"PRIx64" results from vgroup index:%d completed, try next vgroup:%d. total vgroups:%d. current numOfRes:%" PRId64,
+ pSql->self, pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups,
pRes->numOfClauseTotal);
pCmd->command = TSDB_SQL_SELECT;
@@ -1368,12 +1369,12 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
return;
}
- tscDebug("%p all subquery retrieve ts complete, do ts block intersect", pParentSql);
+ tscDebug("0x%"PRIx64" all subquery retrieve ts complete, do ts block intersect", pParentSql->self);
STimeWindow win = TSWINDOW_INITIALIZER;
int64_t num = doTSBlockIntersect(pParentSql, &win);
if (num <= 0) { // no result during ts intersect
- tscDebug("%p no results generated in ts intersection, free all sub SqlObj and quit", pParentSql);
+ tscDebug("0x%"PRIx64" no results generated in ts intersection, free all sub SqlObj and quit", pParentSql->self);
freeJoinSubqueryObj(pParentSql);
// set no result command
@@ -1441,23 +1442,23 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR
}
if ((++pTableMetaInfo->vgroupIndex) < numOfVgroups) {
- tscDebug("%p no result in current vnode anymore, try next vnode, vgIndex:%d", pSql, pTableMetaInfo->vgroupIndex);
+ tscDebug("0x%"PRIx64" no result in current vnode anymore, try next vnode, vgIndex:%d", pSql->self, pTableMetaInfo->vgroupIndex);
pSql->cmd.command = TSDB_SQL_SELECT;
pSql->fp = tscJoinQueryCallback;
tscProcessSql(pSql, NULL);
return;
} else {
- tscDebug("%p no result in current subquery anymore", pSql);
+ tscDebug("0x%"PRIx64" no result in current subquery anymore", pSql->self);
}
}
if (!subAndCheckDone(pSql, pParentSql, pSupporter->subqueryIndex)) {
- tscDebug("%p sub:%p,%d completed, total:%d", pParentSql, tres, pSupporter->subqueryIndex, pState->numOfSub);
+ tscDebug("0x%"PRIx64" sub:%p,%d completed, total:%d", pParentSql->self, tres, pSupporter->subqueryIndex, pState->numOfSub);
return;
}
- tscDebug("%p all %d secondary subqueries retrieval completed, code:%d", tres, pState->numOfSub, pParentSql->res.code);
+ tscDebug("0x%"PRIx64" all %d secondary subqueries retrieval completed, code:%d", pSql->self, pState->numOfSub, pParentSql->res.code);
if (pParentSql->res.code != TSDB_CODE_SUCCESS) {
freeJoinSubqueryObj(pParentSql);
@@ -1468,14 +1469,14 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR
bool stableQuery = tscIsTwoStageSTableQuery(pQueryInfo, 0);
for (int32_t i = 0; i < pState->numOfSub; ++i) {
if (pParentSql->pSubs[i] == NULL) {
- tscDebug("%p %p sub:%d not retrieve data", pParentSql, NULL, i);
+ tscDebug("0x%"PRIx64" %p sub:%d not retrieve data", pParentSql->self, NULL, i);
continue;
}
SSqlRes* pRes1 = &pParentSql->pSubs[i]->res;
if (pRes1->row > 0 && pRes1->numOfRows > 0) {
- tscDebug("%p sub:%p index:%d numOfRows:%d total:%"PRId64 " (not retrieve)", pParentSql, pParentSql->pSubs[i], i,
+ tscDebug("0x%"PRIx64" sub:%p index:%d numOfRows:%d total:%"PRId64 " (not retrieve)", pParentSql->self, pParentSql->pSubs[i], i,
pRes1->numOfRows, pRes1->numOfTotal);
assert(pRes1->row < pRes1->numOfRows);
} else {
@@ -1483,7 +1484,7 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR
pRes1->numOfClauseTotal += pRes1->numOfRows;
}
- tscDebug("%p sub:%p index:%d numOfRows:%d total:%"PRId64, pParentSql, pParentSql->pSubs[i], i,
+ tscDebug("0x%"PRIx64" sub:%p index:%d numOfRows:%d total:%"PRId64, pParentSql->self, pParentSql->pSubs[i], i,
pRes1->numOfRows, pRes1->numOfTotal);
}
}
@@ -1600,7 +1601,7 @@ void tscFetchDatablockForSubquery(SSqlObj* pSql) {
}
if ((++pTableMetaInfo->vgroupIndex) < numOfVgroups) {
- tscDebug("%p no result in current vnode anymore, try next vnode, vgIndex:%d", pSub,
+ tscDebug("0x%"PRIx64" no result in current vnode anymore, try next vnode, vgIndex:%d", pSub->self,
pTableMetaInfo->vgroupIndex);
pSub->cmd.command = TSDB_SQL_SELECT;
pSub->fp = tscJoinQueryCallback;
@@ -1608,7 +1609,7 @@ void tscFetchDatablockForSubquery(SSqlObj* pSql) {
tscProcessSql(pSub, NULL);
tryNextVnode = true;
} else {
- tscDebug("%p no result in current subquery anymore", pSub);
+ tscDebug("0x%"PRIx64" no result in current subquery anymore", pSub->self);
}
}
}
@@ -1631,7 +1632,7 @@ void tscFetchDatablockForSubquery(SSqlObj* pSql) {
// TODO multi-vnode retrieve for projection query with limitation has bugs, since the global limiation is not handled
// retrieve data from current vnode.
- tscDebug("%p retrieve data from %d subqueries", pSql, numOfFetch);
+ tscDebug("0x%"PRIx64" retrieve data from %d subqueries", pSql->self, numOfFetch);
SJoinSupporter* pSupporter = NULL;
for (int32_t i = 0; i < pSql->subState.numOfSub; ++i) {
@@ -1665,7 +1666,7 @@ void tscFetchDatablockForSubquery(SSqlObj* pSql) {
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
if (pRes1->row >= pRes1->numOfRows) {
- tscDebug("%p subquery:%p retrieve data from vnode, subquery:%d, vgroupIndex:%d", pSql, pSql1,
+ tscDebug("0x%"PRIx64" subquery:%p retrieve data from vnode, subquery:%d, vgroupIndex:%d", pSql->self, pSql1,
pSupporter->subqueryIndex, pTableMetaInfo->vgroupIndex);
tscResetForNextRetrieve(pRes1);
@@ -1984,10 +1985,9 @@ void tscHandleMasterJoinQuery(SSqlObj* pSql) {
}
memset(pSql->subState.states, 0, sizeof(*pSql->subState.states) * pSql->subState.numOfSub);
- tscDebug("%p reset all sub states to 0", pSql);
-
- tscDebug("%p start subquery, total:%d", pSql, pQueryInfo->numOfTables);
-
+ tscDebug("0x%"PRIx64" reset all sub states to 0", pSql->self);
+
+ tscDebug("0x%"PRIx64" start subquery, total:%d", pSql->self, pQueryInfo->numOfTables);
for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
SJoinSupporter *pSupporter = tscCreateJoinSupporter(pSql, i);
if (pSupporter == NULL) { // failed to create support struct, abort current query
@@ -2443,7 +2443,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
return ret;
}
- tscDebug("%p retrieved query data from %d vnode(s)", pSql, pState->numOfSub);
+ tscDebug("0x%"PRIx64" retrieved query data from %d vnode(s)", pSql->self, pState->numOfSub);
pSql->pSubs = calloc(pState->numOfSub, POINTER_BYTES);
if (pSql->pSubs == NULL) {
tfree(pSql->pSubs);
@@ -2467,7 +2467,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
}
memset(pState->states, 0, sizeof(*pState->states) * pState->numOfSub);
- tscDebug("%p reset all sub states to 0", pSql);
+ tscDebug("0x%"PRIx64" reset all sub states to 0", pSql->self);
pRes->code = TSDB_CODE_SUCCESS;
@@ -2509,7 +2509,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
assert(pNewQueryInfo->tsBuf != NULL);
}
- tscDebug("%p sub:%p create subquery success. orderOfSub:%d", pSql, pNew, trs->subqueryIndex);
+ tscDebug("0x%"PRIx64" sub:%p create subquery success. orderOfSub:%d", pSql->self, pNew, trs->subqueryIndex);
}
if (i < pState->numOfSub) {
@@ -2531,7 +2531,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
SSqlObj* pSub = pSql->pSubs[j];
SRetrieveSupport* pSupport = pSub->param;
- tscDebug("%p sub:%p launch subquery, orderOfSub:%d.", pSql, pSub, pSupport->subqueryIndex);
+ tscDebug("0x%"PRIx64" sub:%p launch subquery, orderOfSub:%d.", pSql->self, pSub, pSupport->subqueryIndex);
tscProcessSql(pSub, NULL);
}
@@ -2543,11 +2543,11 @@ static void tscFreeRetrieveSup(SSqlObj *pSql) {
void* p = atomic_val_compare_exchange_ptr(&pSql->param, trsupport, 0);
if (p == NULL) {
- tscDebug("%p retrieve supp already released", pSql);
+ tscDebug("0x%"PRIx64" retrieve supp already released", pSql->self);
return;
}
- tscDebug("%p start to free subquery supp obj:%p", pSql, trsupport);
+ tscDebug("0x%"PRIx64" start to free subquery supp obj:%p", pSql->self, trsupport);
tfree(trsupport->localBuffer);
tfree(trsupport);
}
@@ -2651,12 +2651,12 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
*/
pSql->res.numOfRows = 0;
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY; // disable retry efforts
- tscDebug("%p query is cancelled, sub:%p, orderOfSub:%d abort retrieve, code:%s", pParentSql, pSql,
+ tscDebug("0x%"PRIx64" query is cancelled, sub:%p, orderOfSub:%d abort retrieve, code:%s", pParentSql->self, pSql,
subqueryIndex, tstrerror(pParentSql->res.code));
}
if (numOfRows >= 0) { // current query is successful, but other sub query failed, still abort current query.
- tscDebug("%p sub:%p retrieve numOfRows:%d,orderOfSub:%d", pParentSql, pSql, numOfRows, subqueryIndex);
+ tscDebug("0x%"PRIx64" sub:0x%"PRIx64" retrieve numOfRows:%d,orderOfSub:%d", pParentSql->self, pSql->self, numOfRows, subqueryIndex);
tscError("%p sub:%p abort further retrieval due to other queries failure,orderOfSub:%d,code:%s", pParentSql, pSql,
subqueryIndex, tstrerror(pParentSql->res.code));
} else {
@@ -2675,7 +2675,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
}
if (!subAndCheckDone(pSql, pParentSql, subqueryIndex)) {
- tscDebug("%p sub:%p,%d freed, not finished, total:%d", pParentSql, pSql, trsupport->subqueryIndex, pState->numOfSub);
+ tscDebug("0x%"PRIx64" sub:%p,%d freed, not finished, total:%d", pParentSql->self, pSql, trsupport->subqueryIndex, pState->numOfSub);
tscFreeRetrieveSup(pSql);
return;
@@ -2716,7 +2716,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
// data in from current vnode is stored in cache and disk
uint32_t numOfRowsFromSubquery = (uint32_t)(trsupport->pExtMemBuffer[idx]->numOfTotalElems + trsupport->localBuffer->num);
SVgroupsInfo* vgroupsInfo = pTableMetaInfo->vgroupList;
- tscDebug("%p sub:%p all data retrieved from ep:%s, vgId:%d, numOfRows:%d, orderOfSub:%d", pParentSql, pSql,
+ tscDebug("0x%"PRIx64" sub:%p all data retrieved from ep:%s, vgId:%d, numOfRows:%d, orderOfSub:%d", pParentSql->self, pSql,
vgroupsInfo->vgroups[0].epAddr[0].fqdn, vgroupsInfo->vgroups[0].vgId, numOfRowsFromSubquery, idx);
tColModelCompact(pDesc->pColumnModel, trsupport->localBuffer, pDesc->pColumnModel->capacity);
@@ -2745,7 +2745,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
}
if (!subAndCheckDone(pSql, pParentSql, idx)) {
- tscDebug("%p sub:%p orderOfSub:%d freed, not finished", pParentSql, pSql, trsupport->subqueryIndex);
+ tscDebug("0x%"PRIx64" sub:%p orderOfSub:%d freed, not finished", pParentSql->self, pSql, trsupport->subqueryIndex);
tscFreeRetrieveSup(pSql);
return;
@@ -2754,14 +2754,14 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
// all sub-queries are returned, start to local merge process
pDesc->pColumnModel->capacity = trsupport->pExtMemBuffer[idx]->numOfElemsPerPage;
- tscDebug("%p retrieve from %d vnodes completed.final NumOfRows:%" PRId64 ",start to build loser tree", pParentSql,
- pState->numOfSub, pState->numOfRetrievedRows);
+ tscDebug("0x%"PRIx64" retrieve from %d vnodes completed.final NumOfRows:%" PRId64 ",start to build loser tree",
+ pParentSql->self, pState->numOfSub, pState->numOfRetrievedRows);
SQueryInfo *pPQueryInfo = tscGetQueryInfo(&pParentSql->cmd, 0);
tscClearInterpInfo(pPQueryInfo);
tscCreateLocalMerger(trsupport->pExtMemBuffer, pState->numOfSub, pDesc, trsupport->pFinalColModel, trsupport->pFFColModel, pParentSql);
- tscDebug("%p build loser tree completed", pParentSql);
+ tscDebug("0x%"PRIx64" build loser tree completed", pParentSql->self);
pParentSql->res.precision = pSql->res.precision;
pParentSql->res.numOfRows = 0;
@@ -2788,7 +2788,7 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
// this query has been freed already
SRetrieveSupport *trsupport = (SRetrieveSupport *)param;
if (pSql->param == NULL || param == NULL) {
- tscDebug("%p already freed in dnodecallback", pSql);
+ tscDebug("0x%"PRIx64" already freed in dnodecallback", pSql->self);
return;
}
@@ -2803,8 +2803,8 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
if (pParentSql->res.code != TSDB_CODE_SUCCESS) {
trsupport->numOfRetry = MAX_NUM_OF_SUBQUERY_RETRY;
- tscDebug("%p query cancelled/failed, sub:%p, vgId:%d, orderOfSub:%d, code:%s, global code:%s",
- pParentSql, pSql, pVgroup->vgId, trsupport->subqueryIndex, tstrerror(numOfRows), tstrerror(pParentSql->res.code));
+ tscDebug("0x%"PRIx64" query cancelled/failed, sub:%p, vgId:%d, orderOfSub:%d, code:%s, global code:%s",
+ pParentSql->self, pSql, pVgroup->vgId, trsupport->subqueryIndex, tstrerror(numOfRows), tstrerror(pParentSql->res.code));
tscHandleSubqueryError(param, tres, numOfRows);
return;
@@ -2827,7 +2827,7 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
return;
}
} else {
- tscDebug("%p sub:%p reach the max retry times, set global code:%s", pParentSql, pSql, tstrerror(numOfRows));
+ tscDebug("0x%"PRIx64" sub:%p reach the max retry times, set global code:%s", pParentSql->self, pSql, tstrerror(numOfRows));
atomic_val_compare_exchange_32(&pParentSql->res.code, TSDB_CODE_SUCCESS, numOfRows); // set global code and abort
}
@@ -2842,8 +2842,8 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
assert(pRes->numOfRows == numOfRows);
int64_t num = atomic_add_fetch_64(&pState->numOfRetrievedRows, numOfRows);
- tscDebug("%p sub:%p retrieve numOfRows:%d totalNumOfRows:%" PRIu64 " from ep:%s, orderOfSub:%d", pParentSql, pSql,
- pRes->numOfRows, pState->numOfRetrievedRows, pSql->epSet.fqdn[pSql->epSet.inUse], idx);
+ tscDebug("0x%"PRIx64" sub:%p retrieve numOfRows:%d totalNumOfRows:%" PRIu64 " from ep:%s, orderOfSub:%d",
+ pParentSql->self, pSql, pRes->numOfRows, pState->numOfRetrievedRows, pSql->epSet.fqdn[pSql->epSet.inUse], idx);
if (num > tsMaxNumOfOrderedResults && tscIsProjectionQueryOnSTable(pQueryInfo, 0)) {
tscError("%p sub:%p num of OrderedRes is too many, max allowed:%" PRId32 " , current:%" PRId64,
@@ -2967,8 +2967,8 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
return;
}
- tscDebug("%p sub:%p query complete, ep:%s, vgId:%d, orderOfSub:%d, retrieve data", trsupport->pParentSql, pSql,
- pVgroup->epAddr[pSql->epSet.inUse].fqdn, pVgroup->vgId, trsupport->subqueryIndex);
+ tscDebug("0x%"PRIx64" sub:0x%"PRIx64" query complete, ep:%s, vgId:%d, orderOfSub:%d, retrieve data", trsupport->pParentSql->self,
+ pSql->self, pVgroup->epAddr[pSql->epSet.inUse].fqdn, pVgroup->vgId, trsupport->subqueryIndex);
if (pSql->res.qId == 0) { // qhandle is NULL, code is TSDB_CODE_SUCCESS means no results generated from this vnode
tscRetrieveFromDnodeCallBack(param, pSql, 0);
@@ -3031,7 +3031,7 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
}
if (!subAndCheckDone(tres, pParentObj, pSupporter->index)) {
- tscDebug("%p insert:%p,%d completed, total:%d", pParentObj, tres, pSupporter->index, pParentObj->subState.numOfSub);
+ tscDebug("0x%"PRIx64" insert:%p,%d completed, total:%d", pParentObj->self, tres, pSupporter->index, pParentObj->subState.numOfSub);
return;
}
@@ -3041,7 +3041,7 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
doFreeInsertSupporter(pParentObj);
if (pParentObj->res.code == TSDB_CODE_SUCCESS) {
- tscDebug("%p Async insertion completed, total inserted:%d", pParentObj, pParentObj->res.numOfRows);
+ tscDebug("0x%"PRIx64" Async insertion completed, total inserted:%d", pParentObj->self, pParentObj->res.numOfRows);
// todo remove this parameter in async callback function definition.
// all data has been sent to vnode, call user function
@@ -3067,14 +3067,14 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
subquerySetState(pSql, &pParentObj->subState, i, 0);
- tscDebug("%p, failed sub:%d, %p", pParentObj, i, pSql);
+ tscDebug("0x%"PRIx64", failed sub:%d, %p", pParentObj->self, i, pSql);
}
}
tscError("%p Async insertion completed, total inserted:%d rows, numOfFailed:%d, numOfTotal:%d", pParentObj,
pParentObj->res.numOfRows, numOfFailed, numOfSub);
- tscDebug("%p cleanup %d tableMeta in hashTable", pParentObj, pParentObj->cmd.numOfTables);
+ tscDebug("0x%"PRIx64" cleanup %d tableMeta in hashTable", pParentObj->self, pParentObj->cmd.numOfTables);
for(int32_t i = 0; i < pParentObj->cmd.numOfTables; ++i) {
char name[TSDB_TABLE_FNAME_LEN] = {0};
tNameExtractFullName(pParentObj->cmd.pTableNameList[i], name);
@@ -3088,7 +3088,7 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
// in case of insert, redo parsing the sql string and build new submit data block for two reasons:
// 1. the table Id(tid & uid) may have been update, the submit block needs to be updated accordingly.
// 2. vnode may need the schema information along with submit block to update its local table schema.
- tscDebug("%p re-parse sql to generate submit data, retry:%d", pParentObj, pParentObj->retry);
+ tscDebug("0x%"PRIx64" re-parse sql to generate submit data, retry:%d", pParentObj->self, pParentObj->retry);
pParentObj->retry++;
int32_t code = tsParseSql(pParentObj, true);
@@ -3140,7 +3140,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
pSup->pSql = pSql;
pSub->param = pSup;
- tscDebug("%p sub:%p launch sub insert, orderOfSub:%d", pSql, pSub, i);
+ tscDebug("0x%"PRIx64" sub:%p launch sub insert, orderOfSub:%d", pSql->self, pSub, i);
if (pSub->res.code != TSDB_CODE_SUCCESS) {
tscHandleInsertRetry(pSql, pSub);
}
@@ -3168,14 +3168,14 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
}
memset(pSql->subState.states, 0, sizeof(*pSql->subState.states) * pSql->subState.numOfSub);
- tscDebug("%p reset all sub states to 0", pSql);
+ tscDebug("0x%"PRIx64" reset all sub states to 0", pSql->self);
pSql->pSubs = calloc(pSql->subState.numOfSub, POINTER_BYTES);
if (pSql->pSubs == NULL) {
goto _error;
}
- tscDebug("%p submit data to %d vnode(s)", pSql, pSql->subState.numOfSub);
+ tscDebug("0x%"PRIx64" submit data to %d vnode(s)", pSql->self, pSql->subState.numOfSub);
while(numOfSub < pSql->subState.numOfSub) {
SInsertSupporter* pSupporter = calloc(1, sizeof(SInsertSupporter));
@@ -3202,10 +3202,10 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
STableDataBlocks* pTableDataBlock = taosArrayGetP(pCmd->pDataBlocks, numOfSub);
pRes->code = tscCopyDataBlockToPayload(pNew, pTableDataBlock);
if (pRes->code == TSDB_CODE_SUCCESS) {
- tscDebug("%p sub:%p create subObj success. orderOfSub:%d", pSql, pNew, numOfSub);
+ tscDebug("0x%"PRIx64" sub:%p create subObj success. orderOfSub:%d", pSql->self, pNew, numOfSub);
numOfSub++;
} else {
- tscDebug("%p prepare submit data block failed in async insertion, vnodeIdx:%d, total:%d, code:%s", pSql, numOfSub,
+ tscDebug("0x%"PRIx64" prepare submit data block failed in async insertion, vnodeIdx:%d, total:%d, code:%s", pSql->self, numOfSub,
pSql->subState.numOfSub, tstrerror(pRes->code));
goto _error;
}
@@ -3222,7 +3222,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
// use the local variable
for (int32_t j = 0; j < numOfSub; ++j) {
SSqlObj *pSub = pSql->pSubs[j];
- tscDebug("%p sub:%p launch sub insert, orderOfSub:%d", pSql, pSub, j);
+ tscDebug("0x%"PRIx64" sub:%p launch sub insert, orderOfSub:%d", pSql->self, pSub, j);
tscProcessSql(pSub, NULL);
}
diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c
index 70af34ae03..7ef6900a1b 100644
--- a/src/client/src/tscUtil.c
+++ b/src/client/src/tscUtil.c
@@ -841,10 +841,10 @@ void tscFreeSubobj(SSqlObj* pSql) {
return;
}
- tscDebug("%p start to free sub SqlObj, numOfSub:%d", pSql, pSql->subState.numOfSub);
+ tscDebug("0x%"PRIx64" start to free sub SqlObj, numOfSub:%d", pSql->self, pSql->subState.numOfSub);
for(int32_t i = 0; i < pSql->subState.numOfSub; ++i) {
- tscDebug("%p free sub SqlObj:%p, index:%d", pSql, pSql->pSubs[i], i);
+ tscDebug("0x%"PRIx64" free sub SqlObj:%p, index:%d", pSql->self, pSql->pSubs[i], i);
taos_free_result(pSql->pSubs[i]);
pSql->pSubs[i] = NULL;
}
@@ -875,7 +875,7 @@ void tscFreeRegisteredSqlObj(void *pSql) {
int32_t num = atomic_sub_fetch_32(&pTscObj->numOfObj, 1);
int32_t total = atomic_sub_fetch_32(&tscNumOfObj, 1);
- tscDebug("%p free SqlObj, total in tscObj:%d, total:%d", pSql, num, total);
+ tscDebug("0x%"PRIx64" free SqlObj, total in tscObj:%d, total:%d", p->self, num, total);
tscFreeSqlObj(p);
taosReleaseRef(tscRefId, pTscObj->rid);
@@ -898,7 +898,7 @@ void tscFreeSqlObj(SSqlObj* pSql) {
return;
}
- tscDebug("%p start to free sqlObj", pSql);
+ tscDebug("0x%"PRIx64" start to free sqlObj", pSql->self);
pSql->res.code = TSDB_CODE_TSC_QUERY_CANCELLED;
@@ -1294,7 +1294,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, bool freeBlockMap) {
tscSortRemoveDataBlockDupRows(pOneTableBlock);
char* ekey = (char*)pBlocks->data + pOneTableBlock->rowSize*(pBlocks->numOfRows-1);
- tscDebug("%p name:%s, name:%d rows:%d sversion:%d skey:%" PRId64 ", ekey:%" PRId64, pSql, tNameGetTableName(&pOneTableBlock->tableName),
+ tscDebug("0x%"PRIx64" name:%s, name:%d rows:%d sversion:%d skey:%" PRId64 ", ekey:%" PRId64, pSql->self, tNameGetTableName(&pOneTableBlock->tableName),
pBlocks->tid, pBlocks->numOfRows, pBlocks->sversion, GET_INT64_VAL(pBlocks->data), GET_INT64_VAL(ekey));
int32_t len = pBlocks->numOfRows * (pOneTableBlock->rowSize + expandSize) + sizeof(STColumn) * tscGetNumOfColumns(pOneTableBlock->pTableMeta);
@@ -2483,7 +2483,7 @@ void registerSqlObj(SSqlObj* pSql) {
int32_t num = atomic_add_fetch_32(&pSql->pTscObj->numOfObj, 1);
int32_t total = atomic_add_fetch_32(&tscNumOfObj, 1);
- tscDebug("%p new SqlObj from %p, total in tscObj:%d, total:%d", pSql, pSql->pTscObj, num, total);
+ tscDebug("0x%"PRIx64" new SqlObj from %p, total in tscObj:%d, total:%d", pSql->self, pSql->pTscObj, num, total);
}
SSqlObj* createSimpleSubObj(SSqlObj* pSql, __async_cb_func_t fp, void* param, int32_t cmd) {
@@ -2751,7 +2751,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t
tscPrintSelNodeList(pNew, 0);
} else {
- tscDebug("%p new sub insertion: %p, vnodeIdx:%d", pSql, pNew, pTableMetaInfo->vgroupIndex);
+ tscDebug("0x%"PRIx64" new sub insertion: %p, vnodeIdx:%d", pSql->self, pNew, pTableMetaInfo->vgroupIndex);
}
registerSqlObj(pNew);
@@ -3034,7 +3034,7 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) {
int32_t totalVgroups = pTableMetaInfo->vgroupList->numOfVgroups;
if (++pTableMetaInfo->vgroupIndex < totalVgroups) {
- tscDebug("%p results from vgroup index:%d completed, try next:%d. total vgroups:%d. current numOfRes:%" PRId64, pSql,
+ tscDebug("0x%"PRIx64" results from vgroup index:%d completed, try next:%d. total vgroups:%d. current numOfRes:%" PRId64, pSql->self,
pTableMetaInfo->vgroupIndex - 1, pTableMetaInfo->vgroupIndex, totalVgroups, pRes->numOfClauseTotal);
/*
@@ -3053,8 +3053,8 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) {
pQueryInfo->limit.offset = pRes->offset;
assert((pRes->offset >= 0 && pRes->numOfRows == 0) || (pRes->offset == 0 && pRes->numOfRows >= 0));
- tscDebug("%p new query to next vgroup, index:%d, limit:%" PRId64 ", offset:%" PRId64 ", glimit:%" PRId64,
- pSql, pTableMetaInfo->vgroupIndex, pQueryInfo->limit.limit, pQueryInfo->limit.offset, pQueryInfo->clauseLimit);
+ tscDebug("0x%"PRIx64" new query to next vgroup, index:%d, limit:%" PRId64 ", offset:%" PRId64 ", glimit:%" PRId64,
+ pSql->self, pTableMetaInfo->vgroupIndex, pQueryInfo->limit.limit, pQueryInfo->limit.offset, pQueryInfo->clauseLimit);
/*
* For project query with super table join, the numOfSub is equalled to the number of all subqueries.
@@ -3071,7 +3071,7 @@ void tscTryQueryNextVnode(SSqlObj* pSql, __async_cb_func_t fp) {
pSql->fp = fp;
tscProcessSql(pSql, NULL);
} else {
- tscDebug("%p try all %d vnodes, query complete. current numOfRes:%" PRId64, pSql, totalVgroups, pRes->numOfClauseTotal);
+ tscDebug("0x%"PRIx64" try all %d vnodes, query complete. current numOfRes:%" PRId64, pSql->self, totalVgroups, pRes->numOfClauseTotal);
}
}
@@ -3097,7 +3097,7 @@ void tscTryQueryNextClause(SSqlObj* pSql, __async_cb_func_t fp) {
pSql->subState.numOfSub = 0;
pSql->fp = fp;
- tscDebug("%p try data in the next subclause:%d, total subclause:%d", pSql, pCmd->clauseIndex, pCmd->numOfClause);
+ tscDebug("0x%"PRIx64" try data in the next subclause:%d, total subclause:%d", pSql->self, pCmd->clauseIndex, pCmd->numOfClause);
if (pCmd->command > TSDB_SQL_LOCAL) {
tscProcessLocalCmd(pSql);
} else {
diff --git a/src/common/src/tvariant.c b/src/common/src/tvariant.c
index 7009c4d5c3..7798deaa60 100644
--- a/src/common/src/tvariant.c
+++ b/src/common/src/tvariant.c
@@ -48,8 +48,12 @@ 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) {
- pVar->nType = -1; // -1 means error type
- return;
+ // data overflow, try unsigned parse the input number
+ ret = tStrToInteger(token->z, token->type, token->n, &pVar->i64, false);
+ if (ret != 0) {
+ pVar->nType = -1; // -1 means error type
+ return;
+ }
}
break;
@@ -525,6 +529,8 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
}
bool code = false;
+
+ uint64_t ui = 0;
switch(type) {
case TSDB_DATA_TYPE_TINYINT:
code = IS_VALID_TINYINT(*result); break;
@@ -535,13 +541,17 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
case TSDB_DATA_TYPE_BIGINT:
code = IS_VALID_BIGINT(*result); break;
case TSDB_DATA_TYPE_UTINYINT:
- code = IS_VALID_UTINYINT(*result); break;
+ ui = *result;
+ code = IS_VALID_UTINYINT(ui); break;
case TSDB_DATA_TYPE_USMALLINT:
- code = IS_VALID_USMALLINT(*result); break;
+ ui = *result;
+ code = IS_VALID_USMALLINT(ui); break;
case TSDB_DATA_TYPE_UINT:
- code = IS_VALID_UINT(*result); break;
+ ui = *result;
+ code = IS_VALID_UINT(ui); break;
case TSDB_DATA_TYPE_UBIGINT:
- code = IS_VALID_UBIGINT(*result); break;
+ ui = *result;
+ code = IS_VALID_UBIGINT(ui); break;
}
return code? 0:-1;
diff --git a/src/connector/jdbc/CMakeLists.txt b/src/connector/jdbc/CMakeLists.txt
index 5d5a6f5f12..de4b8f6bfb 100644
--- a/src/connector/jdbc/CMakeLists.txt
+++ b/src/connector/jdbc/CMakeLists.txt
@@ -8,7 +8,7 @@ IF (TD_MVN_INSTALLED)
ADD_CUSTOM_COMMAND(OUTPUT ${JDBC_CMD_NAME}
POST_BUILD
COMMAND mvn -Dmaven.test.skip=true install -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml
- COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.27-dist.jar ${LIBRARY_OUTPUT_PATH}
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.28-dist.jar ${LIBRARY_OUTPUT_PATH}
COMMAND mvn -Dmaven.test.skip=true clean -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml
COMMENT "build jdbc driver")
ADD_CUSTOM_TARGET(${JDBC_TARGET_NAME} ALL WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} DEPENDS ${JDBC_CMD_NAME})
diff --git a/src/connector/jdbc/deploy-pom.xml b/src/connector/jdbc/deploy-pom.xml
index d4febe70d6..a31796ffde 100755
--- a/src/connector/jdbc/deploy-pom.xml
+++ b/src/connector/jdbc/deploy-pom.xml
@@ -5,7 +5,7 @@
com.taosdata.jdbc
taos-jdbcdriver
- 2.0.27
+ 2.0.28
jar
JDBCDriver
diff --git a/src/connector/jdbc/pom.xml b/src/connector/jdbc/pom.xml
index b8a88562ab..3400a82e73 100755
--- a/src/connector/jdbc/pom.xml
+++ b/src/connector/jdbc/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.taosdata.jdbc
taos-jdbcdriver
- 2.0.27
+ 2.0.28
jar
JDBCDriver
https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc
diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java
index abd348e68c..4b5b88d93b 100644
--- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java
+++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java
@@ -10,6 +10,7 @@ import java.util.Map;
public abstract class AbstractResultSet extends WrapperImpl implements ResultSet {
private int fetchSize;
+ protected boolean wasNull;
protected void checkAvailability(int columnIndex, int bounds) throws SQLException {
if (isClosed())
@@ -28,7 +29,7 @@ public abstract class AbstractResultSet extends WrapperImpl implements ResultSet
@Override
public boolean wasNull() throws SQLException {
- return false;
+ return wasNull;
}
@Override
diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java
index 32e517f564..db635f5f79 100644
--- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java
+++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java
@@ -6,12 +6,10 @@ import com.google.common.primitives.Ints;
import com.google.common.primitives.Longs;
import com.google.common.primitives.Shorts;
import com.taosdata.jdbc.*;
-import com.taosdata.jdbc.utils.UtcTimestampUtil;
import java.math.BigDecimal;
import java.sql.*;
import java.time.Instant;
-import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.Calendar;
@@ -89,7 +87,7 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet {
String timestampFormat = this.statement.getConnection().getClientInfo(TSDBDriver.PROPERTY_KEY_TIMESTAMP_FORMAT);
if ("TIMESTAMP".equalsIgnoreCase(timestampFormat)) {
Long value = row.getLong(colIndex);
- //TODO:
+ //TODO: this implementation has bug if the timestamp bigger than 9999_9999_9999_9
if (value < 1_0000_0000_0000_0L)
return new Timestamp(value);
long epochSec = value / 1000_000l;
@@ -164,12 +162,12 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet {
}
}
- @Override
- public boolean wasNull() throws SQLException {
- if (isClosed())
- throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
- return resultSet.isEmpty();
- }
+// @Override
+// public boolean wasNull() throws SQLException {
+// if (isClosed())
+// throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED);
+// return resultSet.isEmpty();
+// }
@Override
public String getString(int columnIndex) throws SQLException {
@@ -188,8 +186,11 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet {
checkAvailability(columnIndex, resultSet.get(pos).size());
Object value = resultSet.get(pos).get(columnIndex - 1);
- if (value == null)
+ if (value == null) {
+ wasNull = true;
return false;
+ }
+ wasNull = false;
if (value instanceof Boolean)
return (boolean) value;
return Boolean.valueOf(value.toString());
@@ -200,8 +201,11 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet {
checkAvailability(columnIndex, resultSet.get(pos).size());
Object value = resultSet.get(pos).get(columnIndex - 1);
- if (value == null)
+ if (value == null) {
+ wasNull = true;
return 0;
+ }
+ wasNull = false;
long valueAsLong = Long.parseLong(value.toString());
if (valueAsLong == Byte.MIN_VALUE)
return 0;
@@ -221,8 +225,11 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet {
checkAvailability(columnIndex, resultSet.get(pos).size());
Object value = resultSet.get(pos).get(columnIndex - 1);
- if (value == null)
+ if (value == null) {
+ wasNull = true;
return 0;
+ }
+ wasNull = false;
long valueAsLong = Long.parseLong(value.toString());
if (valueAsLong == Short.MIN_VALUE)
return 0;
@@ -236,8 +243,11 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet {
checkAvailability(columnIndex, resultSet.get(pos).size());
Object value = resultSet.get(pos).get(columnIndex - 1);
- if (value == null)
+ if (value == null) {
+ wasNull = true;
return 0;
+ }
+ wasNull = false;
long valueAsLong = Long.parseLong(value.toString());
if (valueAsLong == Integer.MIN_VALUE)
return 0;
@@ -251,12 +261,14 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet {
checkAvailability(columnIndex, resultSet.get(pos).size());
Object value = resultSet.get(pos).get(columnIndex - 1);
- if (value == null)
+ if (value == null) {
+ wasNull = true;
return 0;
+ }
+ wasNull = false;
if (value instanceof Timestamp) {
return ((Timestamp) value).getTime();
}
-
long valueAsLong = 0;
try {
valueAsLong = Long.parseLong(value.toString());
@@ -273,8 +285,11 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet {
checkAvailability(columnIndex, resultSet.get(pos).size());
Object value = resultSet.get(pos).get(columnIndex - 1);
- if (value == null)
+ if (value == null) {
+ wasNull = true;
return 0;
+ }
+ wasNull = false;
if (value instanceof Float || value instanceof Double)
return (float) value;
return Float.parseFloat(value.toString());
@@ -285,8 +300,11 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet {
checkAvailability(columnIndex, resultSet.get(pos).size());
Object value = resultSet.get(pos).get(columnIndex - 1);
- if (value == null)
+ if (value == null) {
+ wasNull = true;
return 0;
+ }
+ wasNull = false;
if (value instanceof Double || value instanceof Float)
return (double) value;
return Double.parseDouble(value.toString());
diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TD3841Test.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TD3841Test.java
new file mode 100644
index 0000000000..c6fba81eb2
--- /dev/null
+++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TD3841Test.java
@@ -0,0 +1,91 @@
+package com.taosdata.jdbc.cases;
+
+import com.taosdata.jdbc.TSDBDriver;
+import com.taosdata.jdbc.utils.TimestampUtil;
+import org.junit.*;
+
+import java.sql.*;
+import java.util.Properties;
+
+public class TD3841Test {
+ private static final String host = "127.0.0.1";
+ private static Properties properties;
+ private static Connection conn_restful;
+ private static Connection conn_jni;
+
+ @Test
+ public void testRestful() throws SQLException {
+ String url = "jdbc:TAOS-RS://" + host + ":6041/?user=root&password=taosdata";
+ conn_restful = DriverManager.getConnection(url, properties);
+
+ try (Statement stmt = conn_restful.createStatement()) {
+ stmt.execute("drop database if exists test_null");
+ stmt.execute("create database if not exists test_null");
+ stmt.execute("use test_null");
+ stmt.execute("create table weather(ts timestamp, f1 timestamp, f2 int, f3 bigint, f4 float, f5 double, f6 smallint, f7 tinyint, f8 bool, f9 binary(64), f10 nchar(64))");
+ stmt.executeUpdate("insert into weather(ts, f1) values(now+1s, " + TimestampUtil.datetimeToLong("2021-04-21 12:00:00.000") + ")");
+ ResultSet rs = stmt.executeQuery("select * from weather");
+ rs.next();
+
+ Assert.assertEquals("2021-04-21 12:00:00.000", TimestampUtil.longToDatetime(rs.getTimestamp(2).getTime()));
+ Assert.assertEquals(true, rs.getInt(3) == 0 && rs.wasNull());
+ Assert.assertEquals(true, rs.getLong(4) == 0 && rs.wasNull());
+ Assert.assertEquals(true, rs.getFloat(5) == 0.0f && rs.wasNull());
+ Assert.assertEquals(true, rs.getDouble(6) == 0.0f && rs.wasNull());
+ Assert.assertEquals(true, rs.getByte(7) == 0 && rs.wasNull());
+ Assert.assertEquals(true, rs.getShort(8) == 0 && rs.wasNull());
+ Assert.assertEquals(null, rs.getBytes(9));
+ Assert.assertEquals(null, rs.getString(10));
+
+ rs.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testJNI() throws SQLException {
+ final String url = "jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata";
+ conn_jni = DriverManager.getConnection(url, properties);
+
+ try (Statement stmt = conn_jni.createStatement()) {
+ stmt.execute("drop database if exists test_null");
+ stmt.execute("create database if not exists test_null");
+ stmt.execute("use test_null");
+ stmt.execute("create table weather(ts timestamp, f1 timestamp, f2 int, f3 bigint, f4 float, f5 double, f6 smallint, f7 tinyint, f8 bool, f9 binary(64), f10 nchar(64))");
+ stmt.executeUpdate("insert into weather(ts, f1) values(now+1s, " + TimestampUtil.datetimeToLong("2021-04-21 12:00:00.000") + ")");
+ ResultSet rs = stmt.executeQuery("select * from weather");
+ rs.next();
+
+ Assert.assertEquals("2021-04-21 12:00:00.000", TimestampUtil.longToDatetime(rs.getTimestamp(2).getTime()));
+ Assert.assertEquals(true, rs.getInt(3) == 0 && rs.wasNull());
+ Assert.assertEquals(true, rs.getLong(4) == 0 && rs.wasNull());
+ Assert.assertEquals(true, rs.getFloat(5) == 0.0f && rs.wasNull());
+ Assert.assertEquals(true, rs.getDouble(6) == 0.0f && rs.wasNull());
+ Assert.assertEquals(true, rs.getByte(7) == 0 && rs.wasNull());
+ Assert.assertEquals(true, rs.getShort(8) == 0 && rs.wasNull());
+ Assert.assertEquals(null, rs.getBytes(9));
+ Assert.assertEquals(null, rs.getString(10));
+
+ rs.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @BeforeClass
+ public static void beforeClass() {
+ properties = new Properties();
+ properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
+ properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
+ properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
+ }
+
+ @AfterClass
+ public static void afterClass() throws SQLException {
+ if (conn_restful != null)
+ conn_restful.close();
+ if (conn_jni != null)
+ conn_jni.close();
+ }
+}
diff --git a/src/connector/python/linux/python2/setup.py b/src/connector/python/linux/python2/setup.py
index d1fca047c6..ff2d90fcb3 100644
--- a/src/connector/python/linux/python2/setup.py
+++ b/src/connector/python/linux/python2/setup.py
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup(
name="taos",
- version="2.0.7",
+ version="2.0.8",
author="Taosdata Inc.",
author_email="support@taosdata.com",
description="TDengine python client package",
diff --git a/src/connector/python/linux/python2/taos/cursor.py b/src/connector/python/linux/python2/taos/cursor.py
index 8f9aab82da..4c0456b503 100644
--- a/src/connector/python/linux/python2/taos/cursor.py
+++ b/src/connector/python/linux/python2/taos/cursor.py
@@ -42,7 +42,7 @@ class TDengineCursor(object):
def __iter__(self):
return self
- def __next__(self):
+ def next(self):
if self._result is None or self._fields is None:
raise OperationalError("Invalid use of fetch iterator")
diff --git a/src/cq/src/cqMain.c b/src/cq/src/cqMain.c
index d4d202267c..5d5d5f339e 100644
--- a/src/cq/src/cqMain.c
+++ b/src/cq/src/cqMain.c
@@ -310,8 +310,23 @@ void *cqCreate(void *handle, uint64_t uid, int32_t sid, const char* dstTable, ch
}
SCqContext *pContext = handle;
int64_t rid = 0;
+
+ pthread_mutex_lock(&pContext->mutex);
+
+ SCqObj *pObj = pContext->pHead;
+ while (pObj) {
+ if (pObj->uid == uid) {
+ rid = pObj->rid;
+ pthread_mutex_unlock(&pContext->mutex);
+ return (void *)rid;
+ }
+
+ pObj = pObj->next;
+ }
- SCqObj *pObj = calloc(sizeof(SCqObj), 1);
+ pthread_mutex_unlock(&pContext->mutex);
+
+ pObj = calloc(sizeof(SCqObj), 1);
if (pObj == NULL) return NULL;
pObj->uid = uid;
@@ -386,12 +401,15 @@ static void doCreateStream(void *param, TAOS_RES *result, int32_t code) {
if (pObj == NULL) {
return;
}
-
+
SCqContext* pContext = pObj->pContext;
- SSqlObj* pSql = (SSqlObj*)result;
- if (atomic_val_compare_exchange_ptr(&(pContext->dbConn), NULL, pSql->pTscObj) != NULL) {
- taos_close(pSql->pTscObj);
+ SSqlObj* pSql = (SSqlObj*)result;
+ if (code == TSDB_CODE_SUCCESS) {
+ if (atomic_val_compare_exchange_ptr(&(pContext->dbConn), NULL, pSql->pTscObj) != NULL) {
+ taos_close(pSql->pTscObj);
+ }
}
+
pthread_mutex_lock(&pContext->mutex);
cqCreateStream(pContext, pObj);
pthread_mutex_unlock(&pContext->mutex);
@@ -427,10 +445,11 @@ static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) {
pObj->tmrId = taosTmrStart(cqProcessCreateTimer, 1000, (void *)pObj->rid, pContext->tmrCtrl);
return;
}
+
pObj->tmrId = 0;
if (pObj->pStream == NULL) {
- pObj->pStream = taos_open_stream(pContext->dbConn, pObj->sqlStr, cqProcessStreamRes, 0, (void *)pObj->rid, NULL);
+ pObj->pStream = taos_open_stream(pContext->dbConn, pObj->sqlStr, cqProcessStreamRes, INT64_MIN, (void *)pObj->rid, NULL);
// TODO the pObj->pStream may be released if error happens
if (pObj->pStream) {
diff --git a/src/kit/shell/src/shellWindows.c b/src/kit/shell/src/shellWindows.c
index 11c1ac34d8..87d11a3516 100644
--- a/src/kit/shell/src/shellWindows.c
+++ b/src/kit/shell/src/shellWindows.c
@@ -199,15 +199,19 @@ void updateBuffer(Command *cmd) {
}
int isReadyGo(Command *cmd) {
- char total[MAX_COMMAND_SIZE];
+ char *total = malloc(MAX_COMMAND_SIZE);
memset(total, 0, MAX_COMMAND_SIZE);
sprintf(total, "%s%s", cmd->buffer, cmd->command);
char *reg_str =
"(^.*;\\s*$)|(^\\s*$)|(^\\s*exit\\s*$)|(^\\s*q\\s*$)|(^\\s*quit\\s*$)|(^"
"\\s*clear\\s*$)";
- if (regex_match(total, reg_str, REG_EXTENDED | REG_ICASE)) return 1;
+ if (regex_match(total, reg_str, REG_EXTENDED | REG_ICASE)) {
+ free(total);
+ return 1;
+ }
+ free(total);
return 0;
}
diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c
index 01a7e31940..3631fbec1c 100644
--- a/src/kit/taosdemo/taosdemo.c
+++ b/src/kit/taosdemo/taosdemo.c
@@ -97,7 +97,7 @@ enum QUERY_MODE {
#define MAX_TAG_COUNT 128
#define MAX_QUERY_SQL_COUNT 100
-#define MAX_QUERY_SQL_LENGTH 256
+#define MAX_QUERY_SQL_LENGTH 1024
#define MAX_DATABASE_COUNT 256
#define INPUT_BUF_LEN 256
@@ -355,7 +355,7 @@ typedef struct SDbs_S {
} SDbs;
typedef struct SpecifiedQueryInfo_S {
- int rate; // 0: unlimit > 0 loop/s
+ int queryInterval; // 0: unlimit > 0 loop/s
int concurrent;
int sqlCount;
int mode; // 0: sync, 1: async
@@ -371,7 +371,7 @@ typedef struct SpecifiedQueryInfo_S {
typedef struct SuperQueryInfo_S {
char sTblName[MAX_TB_NAME_SIZE+1];
- int rate; // 0: unlimit > 0 loop/s
+ int queryInterval; // 0: unlimit > 0 loop/s
int threadCnt;
int mode; // 0: sync, 1: async
int subscribeInterval; // ms
@@ -530,56 +530,50 @@ char *aggreFunc[] = {"*", "count(*)", "avg(col0)", "sum(col0)",
"max(col0)", "min(col0)", "first(col0)", "last(col0)"};
SArguments g_args = {
- NULL, // metaFile
- 0, // test_mode
- "127.0.0.1", // host
- 6030, // port
- "root", // user
- #ifdef _TD_POWER_
- "powerdb", // password
- #else
- "taosdata", // password
- #endif
- "test", // database
- 1, // replica
- "t", // tb_prefix
- NULL, // sqlFile
- true, // use_metric
- true, // drop_database
- true, // insert_only
- false, // debug_print
- false, // verbose_print
- false, // performance statistic print
- false, // answer_yes;
- "./output.txt", // output_file
- 0, // mode : sync or async
- {
- "TINYINT", // datatype
- "SMALLINT",
- "INT",
- "BIGINT",
- "FLOAT",
- "DOUBLE",
- "BINARY",
- "NCHAR",
- "BOOL",
- "TIMESTAMP"
- },
- 16, // len_of_binary
- 10, // num_of_CPR
- 10, // num_of_connections/thread
- 0, // insert_interval
- 1, // query_times
- 0, // interlace_rows;
- 100, // num_of_RPR
- TSDB_PAYLOAD_SIZE, // max_sql_len
- 10000, // num_of_tables
- 10000, // num_of_DPT
- 0, // abort
- 0, // disorderRatio
- 1000, // disorderRange
- 1, // method_of_delete
- NULL // arg_list
+ NULL, // metaFile
+ 0, // test_mode
+ "127.0.0.1", // host
+ 6030, // port
+ "root", // user
+#ifdef _TD_POWER_
+ "powerdb", // password
+#else
+ "taosdata", // password
+#endif
+ "test", // database
+ 1, // replica
+ "t", // tb_prefix
+ NULL, // sqlFile
+ true, // use_metric
+ true, // drop_database
+ true, // insert_only
+ false, // debug_print
+ false, // verbose_print
+ false, // performance statistic print
+ false, // answer_yes;
+ "./output.txt", // output_file
+ 0, // mode : sync or async
+ {
+ "INT", // datatype
+ "INT", // datatype
+ "INT", // datatype
+ "INT", // datatype
+ },
+ 16, // len_of_binary
+ 4, // num_of_CPR
+ 10, // num_of_connections/thread
+ 0, // insert_interval
+ 1, // query_times
+ 0, // interlace_rows;
+ 30000, // num_of_RPR
+ 1024000, // max_sql_len
+ 10000, // num_of_tables
+ 10000, // num_of_DPT
+ 0, // abort
+ 0, // disorderRatio
+ 1000, // disorderRange
+ 1, // method_of_delete
+ NULL // arg_list
};
@@ -667,7 +661,7 @@ static void printHelp() {
printf("%s%s%s%s\n", indent, "-o", indent,
"Direct output to the named file. Default is './output.txt'.");
printf("%s%s%s%s\n", indent, "-q", indent,
- "Query mode--0: SYNC, 1: ASYNC. Default is SYNC.");
+ "Query mode -- 0: SYNC, 1: ASYNC. Default is SYNC.");
printf("%s%s%s%s\n", indent, "-b", indent,
"The data_type of columns, default: TINYINT,SMALLINT,INT,BIGINT,FLOAT,DOUBLE,BINARY,NCHAR,BOOL,TIMESTAMP.");
printf("%s%s%s%s\n", indent, "-w", indent,
@@ -679,7 +673,7 @@ static void printHelp() {
printf("%s%s%s%s\n", indent, "-i", indent,
"The sleep time (ms) between insertion. Default is 0.");
printf("%s%s%s%s\n", indent, "-r", indent,
- "The number of records per request. Default is 100.");
+ "The number of records per request. Default is 30000.");
printf("%s%s%s%s\n", indent, "-t", indent,
"The number of tables. Default is 10000.");
printf("%s%s%s%s\n", indent, "-n", indent,
@@ -692,13 +686,30 @@ static void printHelp() {
"Out of order data's range, ms, default is 1000.");
printf("%s%s%s%s\n", indent, "-g", indent,
"Print debug info.");
- printf("%s%s%s%s\n", indent, "-V, --version", indent,
+ printf("%s%s%s\n", indent, "-V, --version\t",
"Print version info.");
+ printf("%s%s%s%s\n", indent, "--help\t", indent,
+ "Print command line arguments list info.");
/* printf("%s%s%s%s\n", indent, "-D", indent,
"if elete database if exists. 0: no, 1: yes, default is 1");
*/
}
+static bool isStringNumber(char *input)
+{
+ int len = strlen(input);
+ if (0 == len) {
+ return false;
+ }
+
+ for (int i = 0; i < len; i++) {
+ if (!isdigit(input[i]))
+ return false;
+ }
+
+ return true;
+}
+
static void parse_args(int argc, char *argv[], SArguments *arguments) {
char **sptr;
@@ -706,39 +717,134 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
if (strcmp(argv[i], "-f") == 0) {
arguments->metaFile = argv[++i];
} else if (strcmp(argv[i], "-c") == 0) {
- tstrncpy(configDir, argv[++i], TSDB_FILENAME_LEN);
+ if (argc == i+1) {
+ printHelp();
+ errorPrint("%s", "\n\t-c need a valid path following!\n");
+ exit(EXIT_FAILURE);
+ }
+ tstrncpy(configDir, argv[++i], MAX_FILE_NAME_LEN);
} else if (strcmp(argv[i], "-h") == 0) {
+ if (argc == i+1) {
+ printHelp();
+ errorPrint("%s", "\n\t-h need a valid string following!\n");
+ exit(EXIT_FAILURE);
+ }
arguments->host = argv[++i];
} else if (strcmp(argv[i], "-p") == 0) {
+ if ((argc == i+1) ||
+ (!isStringNumber(argv[i+1]))) {
+ printHelp();
+ errorPrint("%s", "\n\t-p need a number following!\n");
+ exit(EXIT_FAILURE);
+ }
arguments->port = atoi(argv[++i]);
} else if (strcmp(argv[i], "-u") == 0) {
+ if (argc == i+1) {
+ printHelp();
+ errorPrint("%s", "\n\t-u need a valid string following!\n");
+ exit(EXIT_FAILURE);
+ }
arguments->user = argv[++i];
} else if (strcmp(argv[i], "-P") == 0) {
+ if (argc == i+1) {
+ printHelp();
+ errorPrint("%s", "\n\t-P need a valid string following!\n");
+ exit(EXIT_FAILURE);
+ }
arguments->password = argv[++i];
} else if (strcmp(argv[i], "-o") == 0) {
+ if (argc == i+1) {
+ printHelp();
+ errorPrint("%s", "\n\t-o need a valid string following!\n");
+ exit(EXIT_FAILURE);
+ }
arguments->output_file = argv[++i];
} else if (strcmp(argv[i], "-s") == 0) {
+ if (argc == i+1) {
+ printHelp();
+ errorPrint("%s", "\n\t-s need a valid string following!\n");
+ exit(EXIT_FAILURE);
+ }
arguments->sqlFile = argv[++i];
} else if (strcmp(argv[i], "-q") == 0) {
+ if ((argc == i+1) ||
+ (!isStringNumber(argv[i+1]))) {
+ printHelp();
+ errorPrint("%s", "\n\t-q need a number following!\nQuery mode -- 0: SYNC, 1: ASYNC. Default is SYNC.\n");
+ exit(EXIT_FAILURE);
+ }
arguments->query_mode = atoi(argv[++i]);
} else if (strcmp(argv[i], "-T") == 0) {
+ if ((argc == i+1) ||
+ (!isStringNumber(argv[i+1]))) {
+ printHelp();
+ errorPrint("%s", "\n\t-T need a number following!\n");
+ exit(EXIT_FAILURE);
+ }
arguments->num_of_threads = atoi(argv[++i]);
} else if (strcmp(argv[i], "-i") == 0) {
+ if ((argc == i+1) ||
+ (!isStringNumber(argv[i+1]))) {
+ printHelp();
+ errorPrint("%s", "\n\t-i need a number following!\n");
+ exit(EXIT_FAILURE);
+ }
arguments->insert_interval = atoi(argv[++i]);
} else if (strcmp(argv[i], "-qt") == 0) {
+ if ((argc == i+1) ||
+ (!isStringNumber(argv[i+1]))) {
+ printHelp();
+ errorPrint("%s", "\n\t-qt need a number following!\n");
+ exit(EXIT_FAILURE);
+ }
arguments->query_times = atoi(argv[++i]);
} else if (strcmp(argv[i], "-B") == 0) {
+ if ((argc == i+1) ||
+ (!isStringNumber(argv[i+1]))) {
+ printHelp();
+ errorPrint("%s", "\n\t-B need a number following!\n");
+ exit(EXIT_FAILURE);
+ }
arguments->interlace_rows = atoi(argv[++i]);
} else if (strcmp(argv[i], "-r") == 0) {
+ if ((argc == i+1) ||
+ (!isStringNumber(argv[i+1]))) {
+ printHelp();
+ errorPrint("%s", "\n\t-r need a number following!\n");
+ exit(EXIT_FAILURE);
+ }
arguments->num_of_RPR = atoi(argv[++i]);
} else if (strcmp(argv[i], "-t") == 0) {
+ if ((argc == i+1) ||
+ (!isStringNumber(argv[i+1]))) {
+ printHelp();
+ errorPrint("%s", "\n\t-t need a number following!\n");
+ exit(EXIT_FAILURE);
+ }
arguments->num_of_tables = atoi(argv[++i]);
} else if (strcmp(argv[i], "-n") == 0) {
+ if ((argc == i+1) ||
+ (!isStringNumber(argv[i+1]))) {
+ printHelp();
+ errorPrint("%s", "\n\t-n need a number following!\n");
+ exit(EXIT_FAILURE);
+ }
arguments->num_of_DPT = atoi(argv[++i]);
} else if (strcmp(argv[i], "-d") == 0) {
+ if (argc == i+1) {
+ printHelp();
+ errorPrint("%s", "\n\t-d need a valid string following!\n");
+ exit(EXIT_FAILURE);
+ }
arguments->database = argv[++i];
} else if (strcmp(argv[i], "-l") == 0) {
+ if ((argc == i+1) ||
+ (!isStringNumber(argv[i+1]))) {
+ printHelp();
+ errorPrint("%s", "\n\t-l need a number following!\n");
+ exit(EXIT_FAILURE);
+ }
arguments->num_of_CPR = atoi(argv[++i]);
} else if (strcmp(argv[i], "-b") == 0) {
sptr = arguments->datatype;
@@ -746,16 +852,16 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
if (strstr(argv[i], ",") == NULL) {
// only one col
if (strcasecmp(argv[i], "INT")
- && strcasecmp(argv[i], "FLOAT")
- && strcasecmp(argv[i], "TINYINT")
- && strcasecmp(argv[i], "BOOL")
- && strcasecmp(argv[i], "SMALLINT")
- && strcasecmp(argv[i], "BIGINT")
- && strcasecmp(argv[i], "DOUBLE")
- && strcasecmp(argv[i], "BINARY")
- && strcasecmp(argv[i], "NCHAR")) {
+ && strcasecmp(argv[i], "FLOAT")
+ && strcasecmp(argv[i], "TINYINT")
+ && strcasecmp(argv[i], "BOOL")
+ && strcasecmp(argv[i], "SMALLINT")
+ && strcasecmp(argv[i], "BIGINT")
+ && strcasecmp(argv[i], "DOUBLE")
+ && strcasecmp(argv[i], "BINARY")
+ && strcasecmp(argv[i], "NCHAR")) {
printHelp();
- ERROR_EXIT( "Invalid data_type!\n");
+ errorPrint("%s", "-b: Invalid data_type!\n");
exit(EXIT_FAILURE);
}
sptr[0] = argv[i];
@@ -767,17 +873,17 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
char *token = strsep(&running, ",");
while(token != NULL) {
if (strcasecmp(token, "INT")
- && strcasecmp(token, "FLOAT")
- && strcasecmp(token, "TINYINT")
- && strcasecmp(token, "BOOL")
- && strcasecmp(token, "SMALLINT")
- && strcasecmp(token, "BIGINT")
- && strcasecmp(token, "DOUBLE")
- && strcasecmp(token, "BINARY")
- && strcasecmp(token, "NCHAR")) {
+ && strcasecmp(token, "FLOAT")
+ && strcasecmp(token, "TINYINT")
+ && strcasecmp(token, "BOOL")
+ && strcasecmp(token, "SMALLINT")
+ && strcasecmp(token, "BIGINT")
+ && strcasecmp(token, "DOUBLE")
+ && strcasecmp(token, "BINARY")
+ && strcasecmp(token, "NCHAR")) {
printHelp();
free(dupstr);
- ERROR_EXIT("Invalid data_type!\n");
+ errorPrint("%s", "-b: Invalid data_type!\n");
exit(EXIT_FAILURE);
}
sptr[index++] = token;
@@ -788,8 +894,20 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
sptr[index] = NULL;
}
} else if (strcmp(argv[i], "-w") == 0) {
+ if ((argc == i+1) ||
+ (!isStringNumber(argv[i+1]))) {
+ printHelp();
+ errorPrint("%s", "\n\t-w need a number following!\n");
+ exit(EXIT_FAILURE);
+ }
arguments->len_of_binary = atoi(argv[++i]);
} else if (strcmp(argv[i], "-m") == 0) {
+ if ((argc == i+1) ||
+ (!isStringNumber(argv[i+1]))) {
+ printHelp();
+ errorPrint("%s", "\n\t-m need a number following!\n");
+ exit(EXIT_FAILURE);
+ }
arguments->tb_prefix = argv[++i];
} else if (strcmp(argv[i], "-N") == 0) {
arguments->use_metric = false;
@@ -804,22 +922,42 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
} else if (strcmp(argv[i], "-pp") == 0) {
arguments->performance_print = true;
} else if (strcmp(argv[i], "-O") == 0) {
+ if ((argc == i+1) ||
+ (!isStringNumber(argv[i+1]))) {
+ printHelp();
+ errorPrint("%s", "\n\t-O need a number following!\n");
+ exit(EXIT_FAILURE);
+ }
arguments->disorderRatio = atoi(argv[++i]);
- if (arguments->disorderRatio > 50)
+ if (arguments->disorderRatio > 50) {
arguments->disorderRatio = 50;
+ }
- if (arguments->disorderRatio < 0)
+ if (arguments->disorderRatio < 0) {
arguments->disorderRatio = 0;
+ }
} else if (strcmp(argv[i], "-R") == 0) {
+ if ((argc == i+1) ||
+ (!isStringNumber(argv[i+1]))) {
+ printHelp();
+ errorPrint("%s", "\n\t-R need a number following!\n");
+ exit(EXIT_FAILURE);
+ }
arguments->disorderRange = atoi(argv[++i]);
if (arguments->disorderRange < 0)
arguments->disorderRange = 1000;
} else if (strcmp(argv[i], "-a") == 0) {
+ if ((argc == i+1) ||
+ (!isStringNumber(argv[i+1]))) {
+ printHelp();
+ errorPrint("%s", "\n\t-a need a number following!\n");
+ exit(EXIT_FAILURE);
+ }
arguments->replica = atoi(argv[++i]);
if (arguments->replica > 3 || arguments->replica < 1) {
arguments->replica = 1;
@@ -839,29 +977,29 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
exit(0);
} else {
printHelp();
- ERROR_EXIT("ERROR: wrong options\n");
+ errorPrint("%s", "ERROR: wrong options\n");
exit(EXIT_FAILURE);
}
}
if (((arguments->debug_print) && (arguments->metaFile == NULL))
- || arguments->verbose_print) {
+ || arguments->verbose_print) {
printf("###################################################################\n");
printf("# meta file: %s\n", arguments->metaFile);
printf("# Server IP: %s:%hu\n",
- arguments->host == NULL ? "localhost" : arguments->host,
- arguments->port );
+ arguments->host == NULL ? "localhost" : arguments->host,
+ arguments->port );
printf("# User: %s\n", arguments->user);
printf("# Password: %s\n", arguments->password);
printf("# Use metric: %s\n", arguments->use_metric ? "true" : "false");
if (*(arguments->datatype)) {
- printf("# Specified data type: ");
- for (int i = 0; i < MAX_NUM_DATATYPE; i++)
- if (arguments->datatype[i])
- printf("%s,", arguments->datatype[i]);
- else
- break;
- printf("\n");
+ printf("# Specified data type: ");
+ for (int i = 0; i < MAX_NUM_DATATYPE; i++)
+ if (arguments->datatype[i])
+ printf("%s,", arguments->datatype[i]);
+ else
+ break;
+ printf("\n");
}
printf("# Insertion interval: %d\n", arguments->insert_interval);
printf("# Number of records per req: %d\n", arguments->num_of_RPR);
@@ -994,7 +1132,7 @@ static void selectAndGetResult(TAOS *taos, char *command, char* resultFileName)
TAOS_RES *res = taos_query(taos, command);
if (res == NULL || taos_errno(res) != 0) {
errorPrint("%s() LN%d, failed to execute sql:%s, reason:%s\n",
- __func__, __LINE__, command, taos_errstr(res));
+ __func__, __LINE__, command, taos_errstr(res));
taos_free_result(res);
return;
}
@@ -1003,17 +1141,6 @@ static void selectAndGetResult(TAOS *taos, char *command, char* resultFileName)
taos_free_result(res);
}
-static double getCurrentTimeUs() {
- struct timeval tv;
-
- if (gettimeofday(&tv, NULL) != 0) {
- perror("Failed to get current time in ms");
- return 0.0;
- }
-
- return tv.tv_sec + tv.tv_usec / 1E6;
-}
-
static int32_t rand_bool(){
static int cursor;
cursor++;
@@ -1108,7 +1235,7 @@ static void init_rand_data() {
g_args.metaFile); } while(0)
static int printfInsertMeta() {
- SHOW_PARSE_RESULT_START();
+ SHOW_PARSE_RESULT_START();
printf("host: \033[33m%s:%u\033[0m\n", g_Dbs.host, g_Dbs.port);
printf("user: \033[33m%s\033[0m\n", g_Dbs.user);
@@ -1170,23 +1297,23 @@ static int printfInsertMeta() {
}
if (g_Dbs.db[i].dbCfg.precision[0] != 0) {
if ((0 == strncasecmp(g_Dbs.db[i].dbCfg.precision, "ms", 2))
- || (0 == strncasecmp(g_Dbs.db[i].dbCfg.precision, "us", 2))) {
+ || (0 == strncasecmp(g_Dbs.db[i].dbCfg.precision, "us", 2))) {
printf(" precision: \033[33m%s\033[0m\n",
- g_Dbs.db[i].dbCfg.precision);
+ g_Dbs.db[i].dbCfg.precision);
} else {
printf("\033[1m\033[40;31m precision error: %s\033[0m\n",
- g_Dbs.db[i].dbCfg.precision);
+ g_Dbs.db[i].dbCfg.precision);
return -1;
}
}
printf(" super table count: \033[33m%d\033[0m\n",
- g_Dbs.db[i].superTblCount);
+ g_Dbs.db[i].superTblCount);
for (int j = 0; j < g_Dbs.db[i].superTblCount; j++) {
printf(" super table[\033[33m%d\033[0m]:\n", j);
printf(" stbName: \033[33m%s\033[0m\n",
- g_Dbs.db[i].superTbls[j].sTblName);
+ g_Dbs.db[i].superTbls[j].sTblName);
if (PRE_CREATE_SUBTBL == g_Dbs.db[i].superTbls[j].autoCreateTable) {
printf(" autoCreateTable: \033[33m%s\033[0m\n", "no");
@@ -1205,23 +1332,23 @@ static int printfInsertMeta() {
}
printf(" childTblCount: \033[33m%d\033[0m\n",
- g_Dbs.db[i].superTbls[j].childTblCount);
+ g_Dbs.db[i].superTbls[j].childTblCount);
printf(" childTblPrefix: \033[33m%s\033[0m\n",
- g_Dbs.db[i].superTbls[j].childTblPrefix);
+ g_Dbs.db[i].superTbls[j].childTblPrefix);
printf(" dataSource: \033[33m%s\033[0m\n",
- g_Dbs.db[i].superTbls[j].dataSource);
+ g_Dbs.db[i].superTbls[j].dataSource);
printf(" insertMode: \033[33m%s\033[0m\n",
- g_Dbs.db[i].superTbls[j].insertMode);
+ g_Dbs.db[i].superTbls[j].insertMode);
if (g_Dbs.db[i].superTbls[j].childTblLimit > 0) {
printf(" childTblLimit: \033[33m%d\033[0m\n",
- g_Dbs.db[i].superTbls[j].childTblLimit);
+ g_Dbs.db[i].superTbls[j].childTblLimit);
}
if (g_Dbs.db[i].superTbls[j].childTblOffset >= 0) {
printf(" childTblOffset: \033[33m%d\033[0m\n",
- g_Dbs.db[i].superTbls[j].childTblOffset);
+ g_Dbs.db[i].superTbls[j].childTblOffset);
}
printf(" insertRows: \033[33m%"PRId64"\033[0m\n",
- g_Dbs.db[i].superTbls[j].insertRows);
+ g_Dbs.db[i].superTbls[j].insertRows);
if (0 == g_Dbs.db[i].superTbls[j].multiThreadWriteOneTbl) {
printf(" multiThreadWriteOneTbl: \033[33mno\033[0m\n");
@@ -1229,61 +1356,61 @@ static int printfInsertMeta() {
printf(" multiThreadWriteOneTbl: \033[33myes\033[0m\n");
}
printf(" interlaceRows: \033[33m%d\033[0m\n",
- g_Dbs.db[i].superTbls[j].interlaceRows);
+ g_Dbs.db[i].superTbls[j].interlaceRows);
if (g_Dbs.db[i].superTbls[j].interlaceRows > 0) {
printf(" stable insert interval: \033[33m%d\033[0m\n",
- g_Dbs.db[i].superTbls[j].insertInterval);
+ g_Dbs.db[i].superTbls[j].insertInterval);
}
printf(" disorderRange: \033[33m%d\033[0m\n",
- g_Dbs.db[i].superTbls[j].disorderRange);
+ g_Dbs.db[i].superTbls[j].disorderRange);
printf(" disorderRatio: \033[33m%d\033[0m\n",
- g_Dbs.db[i].superTbls[j].disorderRatio);
+ g_Dbs.db[i].superTbls[j].disorderRatio);
printf(" maxSqlLen: \033[33m%d\033[0m\n",
- g_Dbs.db[i].superTbls[j].maxSqlLen);
+ g_Dbs.db[i].superTbls[j].maxSqlLen);
printf(" timeStampStep: \033[33m%d\033[0m\n",
- g_Dbs.db[i].superTbls[j].timeStampStep);
+ g_Dbs.db[i].superTbls[j].timeStampStep);
printf(" startTimestamp: \033[33m%s\033[0m\n",
- g_Dbs.db[i].superTbls[j].startTimestamp);
+ g_Dbs.db[i].superTbls[j].startTimestamp);
printf(" sampleFormat: \033[33m%s\033[0m\n",
- g_Dbs.db[i].superTbls[j].sampleFormat);
+ g_Dbs.db[i].superTbls[j].sampleFormat);
printf(" sampleFile: \033[33m%s\033[0m\n",
- g_Dbs.db[i].superTbls[j].sampleFile);
+ g_Dbs.db[i].superTbls[j].sampleFile);
printf(" tagsFile: \033[33m%s\033[0m\n",
- g_Dbs.db[i].superTbls[j].tagsFile);
+ g_Dbs.db[i].superTbls[j].tagsFile);
printf(" columnCount: \033[33m%d\033[0m\n",
- g_Dbs.db[i].superTbls[j].columnCount);
+ g_Dbs.db[i].superTbls[j].columnCount);
for (int k = 0; k < g_Dbs.db[i].superTbls[j].columnCount; k++) {
//printf("dataType:%s, dataLen:%d\t", g_Dbs.db[i].superTbls[j].columns[k].dataType, g_Dbs.db[i].superTbls[j].columns[k].dataLen);
if ((0 == strncasecmp(g_Dbs.db[i].superTbls[j].columns[k].dataType,
- "binary", 6))
- || (0 == strncasecmp(g_Dbs.db[i].superTbls[j].columns[k].dataType,
- "nchar", 5))) {
+ "binary", 6))
+ || (0 == strncasecmp(g_Dbs.db[i].superTbls[j].columns[k].dataType,
+ "nchar", 5))) {
printf("column[\033[33m%d\033[0m]:\033[33m%s(%d)\033[0m ", k,
- g_Dbs.db[i].superTbls[j].columns[k].dataType,
- g_Dbs.db[i].superTbls[j].columns[k].dataLen);
+ g_Dbs.db[i].superTbls[j].columns[k].dataType,
+ g_Dbs.db[i].superTbls[j].columns[k].dataLen);
} else {
printf("column[%d]:\033[33m%s\033[0m ", k,
- g_Dbs.db[i].superTbls[j].columns[k].dataType);
+ g_Dbs.db[i].superTbls[j].columns[k].dataType);
}
}
printf("\n");
printf(" tagCount: \033[33m%d\033[0m\n ",
- g_Dbs.db[i].superTbls[j].tagCount);
+ g_Dbs.db[i].superTbls[j].tagCount);
for (int k = 0; k < g_Dbs.db[i].superTbls[j].tagCount; k++) {
//printf("dataType:%s, dataLen:%d\t", g_Dbs.db[i].superTbls[j].tags[k].dataType, g_Dbs.db[i].superTbls[j].tags[k].dataLen);
if ((0 == strncasecmp(g_Dbs.db[i].superTbls[j].tags[k].dataType,
- "binary", strlen("binary")))
- || (0 == strncasecmp(g_Dbs.db[i].superTbls[j].tags[k].dataType,
- "nchar", strlen("nchar")))) {
+ "binary", strlen("binary")))
+ || (0 == strncasecmp(g_Dbs.db[i].superTbls[j].tags[k].dataType,
+ "nchar", strlen("nchar")))) {
printf("tag[%d]:\033[33m%s(%d)\033[0m ", k,
- g_Dbs.db[i].superTbls[j].tags[k].dataType,
- g_Dbs.db[i].superTbls[j].tags[k].dataLen);
+ g_Dbs.db[i].superTbls[j].tags[k].dataType,
+ g_Dbs.db[i].superTbls[j].tags[k].dataLen);
} else {
printf("tag[%d]:\033[33m%s\033[0m ", k,
- g_Dbs.db[i].superTbls[j].tags[k].dataType);
+ g_Dbs.db[i].superTbls[j].tags[k].dataType);
}
}
printf("\n");
@@ -1357,7 +1484,7 @@ static void printfInsertMetaToFile(FILE* fp) {
}
if (g_Dbs.db[i].dbCfg.precision[0] != 0) {
if ((0 == strncasecmp(g_Dbs.db[i].dbCfg.precision, "ms", 2))
- || (0 == strncasecmp(g_Dbs.db[i].dbCfg.precision, "us", 2))) {
+ || (0 == strncasecmp(g_Dbs.db[i].dbCfg.precision, "us", 2))) {
fprintf(fp, " precision: %s\n", g_Dbs.db[i].dbCfg.precision);
} else {
fprintf(fp, " precision error: %s\n", g_Dbs.db[i].dbCfg.precision);
@@ -1424,10 +1551,10 @@ static void printfInsertMetaToFile(FILE* fp) {
for (int k = 0; k < g_Dbs.db[i].superTbls[j].columnCount; k++) {
//printf("dataType:%s, dataLen:%d\t", g_Dbs.db[i].superTbls[j].columns[k].dataType, g_Dbs.db[i].superTbls[j].columns[k].dataLen);
if ((0 == strncasecmp(
- g_Dbs.db[i].superTbls[j].columns[k].dataType,
- "binary", strlen("binary")))
- || (0 == strncasecmp(g_Dbs.db[i].superTbls[j].columns[k].dataType,
- "nchar", strlen("nchar")))) {
+ g_Dbs.db[i].superTbls[j].columns[k].dataType,
+ "binary", strlen("binary")))
+ || (0 == strncasecmp(g_Dbs.db[i].superTbls[j].columns[k].dataType,
+ "nchar", strlen("nchar")))) {
fprintf(fp, "column[%d]:%s(%d) ", k,
g_Dbs.db[i].superTbls[j].columns[k].dataType,
g_Dbs.db[i].superTbls[j].columns[k].dataLen);
@@ -1442,9 +1569,9 @@ static void printfInsertMetaToFile(FILE* fp) {
for (int k = 0; k < g_Dbs.db[i].superTbls[j].tagCount; k++) {
//printf("dataType:%s, dataLen:%d\t", g_Dbs.db[i].superTbls[j].tags[k].dataType, g_Dbs.db[i].superTbls[j].tags[k].dataLen);
if ((0 == strncasecmp(g_Dbs.db[i].superTbls[j].tags[k].dataType,
- "binary", strlen("binary")))
- || (0 == strncasecmp(g_Dbs.db[i].superTbls[j].tags[k].dataType,
- "nchar", strlen("nchar")))) {
+ "binary", strlen("binary")))
+ || (0 == strncasecmp(g_Dbs.db[i].superTbls[j].tags[k].dataType,
+ "nchar", strlen("nchar")))) {
fprintf(fp, "tag[%d]:%s(%d) ", k, g_Dbs.db[i].superTbls[j].tags[k].dataType,
g_Dbs.db[i].superTbls[j].tags[k].dataLen);
} else {
@@ -1464,67 +1591,67 @@ static void printfQueryMeta() {
SHOW_PARSE_RESULT_START();
printf("host: \033[33m%s:%u\033[0m\n",
- g_queryInfo.host, g_queryInfo.port);
+ g_queryInfo.host, g_queryInfo.port);
printf("user: \033[33m%s\033[0m\n", g_queryInfo.user);
printf("database name: \033[33m%s\033[0m\n", g_queryInfo.dbName);
printf("\n");
printf("specified table query info: \n");
- printf("query interval: \033[33m%d\033[0m\n",
- g_queryInfo.specifiedQueryInfo.rate);
+ printf("query interval: \033[33m%d ms\033[0m\n",
+ g_queryInfo.specifiedQueryInfo.queryInterval);
printf("top query times:\033[33m%d\033[0m\n", g_args.query_times);
printf("concurrent: \033[33m%d\033[0m\n",
- g_queryInfo.specifiedQueryInfo.concurrent);
+ g_queryInfo.specifiedQueryInfo.concurrent);
printf("sqlCount: \033[33m%d\033[0m\n",
- g_queryInfo.specifiedQueryInfo.sqlCount);
+ g_queryInfo.specifiedQueryInfo.sqlCount);
printf("specified tbl query times:\n");
printf(" \033[33m%d\033[0m\n",
- g_queryInfo.specifiedQueryInfo.queryTimes);
+ g_queryInfo.specifiedQueryInfo.queryTimes);
if (SUBSCRIBE_TEST == g_args.test_mode) {
printf("mod: \033[33m%d\033[0m\n",
- g_queryInfo.specifiedQueryInfo.mode);
+ g_queryInfo.specifiedQueryInfo.mode);
printf("interval: \033[33m%d\033[0m\n",
- g_queryInfo.specifiedQueryInfo.subscribeInterval);
+ g_queryInfo.specifiedQueryInfo.subscribeInterval);
printf("restart: \033[33m%d\033[0m\n",
- g_queryInfo.specifiedQueryInfo.subscribeRestart);
+ g_queryInfo.specifiedQueryInfo.subscribeRestart);
printf("keepProgress: \033[33m%d\033[0m\n",
- g_queryInfo.specifiedQueryInfo.subscribeKeepProgress);
+ g_queryInfo.specifiedQueryInfo.subscribeKeepProgress);
}
for (int i = 0; i < g_queryInfo.specifiedQueryInfo.sqlCount; i++) {
printf(" sql[%d]: \033[33m%s\033[0m\n",
- i, g_queryInfo.specifiedQueryInfo.sql[i]);
+ i, g_queryInfo.specifiedQueryInfo.sql[i]);
}
printf("\n");
printf("super table query info:\n");
printf("query interval: \033[33m%d\033[0m\n",
- g_queryInfo.superQueryInfo.rate);
+ g_queryInfo.superQueryInfo.queryInterval);
printf("threadCnt: \033[33m%d\033[0m\n",
- g_queryInfo.superQueryInfo.threadCnt);
+ g_queryInfo.superQueryInfo.threadCnt);
printf("childTblCount: \033[33m%d\033[0m\n",
- g_queryInfo.superQueryInfo.childTblCount);
+ g_queryInfo.superQueryInfo.childTblCount);
printf("stable name: \033[33m%s\033[0m\n",
- g_queryInfo.superQueryInfo.sTblName);
+ g_queryInfo.superQueryInfo.sTblName);
printf("stb query times:\033[33m%d\033[0m\n",
- g_queryInfo.superQueryInfo.queryTimes);
+ g_queryInfo.superQueryInfo.queryTimes);
if (SUBSCRIBE_TEST == g_args.test_mode) {
printf("mod: \033[33m%d\033[0m\n",
- g_queryInfo.superQueryInfo.mode);
+ g_queryInfo.superQueryInfo.mode);
printf("interval: \033[33m%d\033[0m\n",
- g_queryInfo.superQueryInfo.subscribeInterval);
+ g_queryInfo.superQueryInfo.subscribeInterval);
printf("restart: \033[33m%d\033[0m\n",
- g_queryInfo.superQueryInfo.subscribeRestart);
+ g_queryInfo.superQueryInfo.subscribeRestart);
printf("keepProgress: \033[33m%d\033[0m\n",
- g_queryInfo.superQueryInfo.subscribeKeepProgress);
+ g_queryInfo.superQueryInfo.subscribeKeepProgress);
}
printf("sqlCount: \033[33m%d\033[0m\n",
- g_queryInfo.superQueryInfo.sqlCount);
+ g_queryInfo.superQueryInfo.sqlCount);
for (int i = 0; i < g_queryInfo.superQueryInfo.sqlCount; i++) {
printf(" sql[%d]: \033[33m%s\033[0m\n",
- i, g_queryInfo.superQueryInfo.sql[i]);
+ i, g_queryInfo.superQueryInfo.sql[i]);
}
printf("\n");
@@ -1564,7 +1691,7 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
}
static void xDumpFieldToFile(FILE* fp, const char* val,
- TAOS_FIELD* field, int32_t length, int precision) {
+ TAOS_FIELD* field, int32_t length, int precision) {
if (val == NULL) {
fprintf(fp, "%s", TSDB_DATA_NULL_STR);
@@ -1671,7 +1798,7 @@ static int getDbFromServer(TAOS * taos, SDbInfo** dbInfos) {
while((row = taos_fetch_row(res)) != NULL) {
// sys database name : 'log'
if (strncasecmp(row[TSDB_SHOW_DB_NAME_INDEX], "log",
- fields[TSDB_SHOW_DB_NAME_INDEX].bytes) == 0) {
+ fields[TSDB_SHOW_DB_NAME_INDEX].bytes) == 0) {
continue;
}
@@ -1682,10 +1809,10 @@ static int getDbFromServer(TAOS * taos, SDbInfo** dbInfos) {
}
tstrncpy(dbInfos[count]->name, (char *)row[TSDB_SHOW_DB_NAME_INDEX],
- fields[TSDB_SHOW_DB_NAME_INDEX].bytes);
+ fields[TSDB_SHOW_DB_NAME_INDEX].bytes);
formatTimestamp(dbInfos[count]->create_time,
- *(int64_t*)row[TSDB_SHOW_DB_CREATED_TIME_INDEX],
- TSDB_TIME_PRECISION_MILLI);
+ *(int64_t*)row[TSDB_SHOW_DB_CREATED_TIME_INDEX],
+ TSDB_TIME_PRECISION_MILLI);
dbInfos[count]->ntables = *((int32_t *)row[TSDB_SHOW_DB_NTABLES_INDEX]);
dbInfos[count]->vgroups = *((int32_t *)row[TSDB_SHOW_DB_VGROUPS_INDEX]);
dbInfos[count]->replica = *((int16_t *)row[TSDB_SHOW_DB_REPLICA_INDEX]);
@@ -1693,7 +1820,7 @@ static int getDbFromServer(TAOS * taos, SDbInfo** dbInfos) {
dbInfos[count]->days = *((int16_t *)row[TSDB_SHOW_DB_DAYS_INDEX]);
tstrncpy(dbInfos[count]->keeplist, (char *)row[TSDB_SHOW_DB_KEEP_INDEX],
- fields[TSDB_SHOW_DB_KEEP_INDEX].bytes);
+ fields[TSDB_SHOW_DB_KEEP_INDEX].bytes);
dbInfos[count]->cache = *((int32_t *)row[TSDB_SHOW_DB_CACHE_INDEX]);
dbInfos[count]->blocks = *((int32_t *)row[TSDB_SHOW_DB_BLOCKS_INDEX]);
dbInfos[count]->minrows = *((int32_t *)row[TSDB_SHOW_DB_MINROWS_INDEX]);
@@ -1702,19 +1829,19 @@ static int getDbFromServer(TAOS * taos, SDbInfo** dbInfos) {
dbInfos[count]->fsync = *((int32_t *)row[TSDB_SHOW_DB_FSYNC_INDEX]);
dbInfos[count]->comp = (int8_t)(*((int8_t *)row[TSDB_SHOW_DB_COMP_INDEX]));
dbInfos[count]->cachelast =
- (int8_t)(*((int8_t *)row[TSDB_SHOW_DB_CACHELAST_INDEX]));
+ (int8_t)(*((int8_t *)row[TSDB_SHOW_DB_CACHELAST_INDEX]));
tstrncpy(dbInfos[count]->precision,
- (char *)row[TSDB_SHOW_DB_PRECISION_INDEX],
- fields[TSDB_SHOW_DB_PRECISION_INDEX].bytes);
+ (char *)row[TSDB_SHOW_DB_PRECISION_INDEX],
+ fields[TSDB_SHOW_DB_PRECISION_INDEX].bytes);
dbInfos[count]->update = *((int8_t *)row[TSDB_SHOW_DB_UPDATE_INDEX]);
tstrncpy(dbInfos[count]->status, (char *)row[TSDB_SHOW_DB_STATUS_INDEX],
- fields[TSDB_SHOW_DB_STATUS_INDEX].bytes);
+ fields[TSDB_SHOW_DB_STATUS_INDEX].bytes);
count++;
if (count > MAX_DATABASE_COUNT) {
errorPrint("%s() LN%d, The database count overflow than %d\n",
- __func__, __LINE__, MAX_DATABASE_COUNT);
+ __func__, __LINE__, MAX_DATABASE_COUNT);
break;
}
}
@@ -1723,10 +1850,10 @@ static int getDbFromServer(TAOS * taos, SDbInfo** dbInfos) {
}
static void printfDbInfoForQueryToFile(
- char* filename, SDbInfo* dbInfos, int index) {
+ char* filename, SDbInfo* dbInfos, int index) {
if (filename[0] == 0)
- return;
+ return;
FILE *fp = fopen(filename, "at");
if (fp == NULL) {
@@ -1769,8 +1896,8 @@ static void printfQuerySystemInfo(TAOS * taos) {
time(&t);
lt = localtime(&t);
snprintf(filename, MAX_QUERY_SQL_LENGTH, "querySystemInfo-%d-%d-%d %d:%d:%d",
- lt->tm_year+1900, lt->tm_mon, lt->tm_mday, lt->tm_hour, lt->tm_min,
- lt->tm_sec);
+ lt->tm_year+1900, lt->tm_mon, lt->tm_mday, lt->tm_hour, lt->tm_min,
+ lt->tm_sec);
// show variables
res = taos_query(taos, "show variables;");
@@ -1791,8 +1918,8 @@ static void printfQuerySystemInfo(TAOS * taos) {
}
int dbCount = getDbFromServer(taos, dbInfos);
if (dbCount <= 0) {
- free(dbInfos);
- return;
+ free(dbInfos);
+ return;
}
for (int i = 0; i < dbCount; i++) {
@@ -1817,182 +1944,184 @@ static void printfQuerySystemInfo(TAOS * taos) {
static int postProceSql(char* host, uint16_t port, char* sqlstr)
{
- char *req_fmt = "POST %s HTTP/1.1\r\nHost: %s:%d\r\nAccept: */*\r\nAuthorization: Basic %s\r\nContent-Length: %d\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n%s";
+ char *req_fmt = "POST %s HTTP/1.1\r\nHost: %s:%d\r\nAccept: */*\r\nAuthorization: Basic %s\r\nContent-Length: %d\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n%s";
- char *url = "/rest/sql";
+ char *url = "/rest/sql";
- struct hostent *server;
- struct sockaddr_in serv_addr;
- int bytes, sent, received, req_str_len, resp_len;
- char *request_buf;
- char response_buf[RESP_BUF_LEN];
- uint16_t rest_port = port + TSDB_PORT_HTTP;
+ struct hostent *server;
+ struct sockaddr_in serv_addr;
+ int bytes, sent, received, req_str_len, resp_len;
+ char *request_buf;
+ char response_buf[RESP_BUF_LEN];
+ uint16_t rest_port = port + TSDB_PORT_HTTP;
- int req_buf_len = strlen(sqlstr) + REQ_EXTRA_BUF_LEN;
+ int req_buf_len = strlen(sqlstr) + REQ_EXTRA_BUF_LEN;
- request_buf = malloc(req_buf_len);
- if (NULL == request_buf)
- ERROR_EXIT("ERROR, cannot allocate memory.");
+ request_buf = malloc(req_buf_len);
+ if (NULL == request_buf) {
+ errorPrint("%s", "ERROR, cannot allocate memory.\n");
+ exit(EXIT_FAILURE);
+ }
- char userpass_buf[INPUT_BUF_LEN];
- int mod_table[] = {0, 2, 1};
+ char userpass_buf[INPUT_BUF_LEN];
+ int mod_table[] = {0, 2, 1};
- static char base64[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
- 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
- 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
- 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
- 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
- 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
- 'w', 'x', 'y', 'z', '0', '1', '2', '3',
- '4', '5', '6', '7', '8', '9', '+', '/'};
+ static char base64[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
+ 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
+ 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
+ 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
+ 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
+ 'w', 'x', 'y', 'z', '0', '1', '2', '3',
+ '4', '5', '6', '7', '8', '9', '+', '/'};
- snprintf(userpass_buf, INPUT_BUF_LEN, "%s:%s",
- g_Dbs.user, g_Dbs.password);
- size_t userpass_buf_len = strlen(userpass_buf);
- size_t encoded_len = 4 * ((userpass_buf_len +2) / 3);
+ snprintf(userpass_buf, INPUT_BUF_LEN, "%s:%s",
+ g_Dbs.user, g_Dbs.password);
+ size_t userpass_buf_len = strlen(userpass_buf);
+ size_t encoded_len = 4 * ((userpass_buf_len +2) / 3);
- char base64_buf[INPUT_BUF_LEN];
+ char base64_buf[INPUT_BUF_LEN];
#ifdef WINDOWS
- WSADATA wsaData;
+ WSADATA wsaData;
WSAStartup(MAKEWORD(2, 2), &wsaData);
SOCKET sockfd;
#else
- int sockfd;
+ int sockfd;
#endif
- sockfd = socket(AF_INET, SOCK_STREAM, 0);
- if (sockfd < 0) {
+ sockfd = socket(AF_INET, SOCK_STREAM, 0);
+ if (sockfd < 0) {
#ifdef WINDOWS
- errorPrint( "Could not create socket : %d" , WSAGetLastError());
+ errorPrint( "Could not create socket : %d" , WSAGetLastError());
#endif
- debugPrint("%s() LN%d, sockfd=%d\n", __func__, __LINE__, sockfd);
- free(request_buf);
- ERROR_EXIT("ERROR opening socket");
- }
-
- server = gethostbyname(host);
- if (server == NULL) {
- free(request_buf);
- ERROR_EXIT("ERROR, no such host");
- }
-
- debugPrint("h_name: %s\nh_addretype: %s\nh_length: %d\n",
- server->h_name,
- (server->h_addrtype == AF_INET)?"ipv4":"ipv6",
- server->h_length);
-
- memset(&serv_addr, 0, sizeof(serv_addr));
- serv_addr.sin_family = AF_INET;
- serv_addr.sin_port = htons(rest_port);
-#ifdef WINDOWS
- serv_addr.sin_addr.s_addr = inet_addr(host);
-#else
- memcpy(&serv_addr.sin_addr.s_addr,server->h_addr,server->h_length);
-#endif
-
- int retConn = connect(sockfd,(struct sockaddr *)&serv_addr,sizeof(serv_addr));
- debugPrint("%s() LN%d connect() return %d\n", __func__, __LINE__, retConn);
- if (retConn < 0) {
- free(request_buf);
- ERROR_EXIT("ERROR connecting");
- }
-
- memset(base64_buf, 0, INPUT_BUF_LEN);
-
- for (int n = 0, m = 0; n < userpass_buf_len;) {
- uint32_t oct_a = n < userpass_buf_len ?
- (unsigned char) userpass_buf[n++]:0;
- uint32_t oct_b = n < userpass_buf_len ?
- (unsigned char) userpass_buf[n++]:0;
- uint32_t oct_c = n < userpass_buf_len ?
- (unsigned char) userpass_buf[n++]:0;
- uint32_t triple = (oct_a << 0x10) + (oct_b << 0x08) + oct_c;
-
- base64_buf[m++] = base64[(triple >> 3* 6) & 0x3f];
- base64_buf[m++] = base64[(triple >> 2* 6) & 0x3f];
- base64_buf[m++] = base64[(triple >> 1* 6) & 0x3f];
- base64_buf[m++] = base64[(triple >> 0* 6) & 0x3f];
- }
-
- for (int l = 0; l < mod_table[userpass_buf_len % 3]; l++)
- base64_buf[encoded_len - 1 - l] = '=';
-
- debugPrint("%s() LN%d: auth string base64 encoded: %s\n",
- __func__, __LINE__, base64_buf);
- char *auth = base64_buf;
-
- int r = snprintf(request_buf,
- req_buf_len,
- req_fmt, url, host, rest_port,
- auth, strlen(sqlstr), sqlstr);
- if (r >= req_buf_len) {
- free(request_buf);
- ERROR_EXIT("ERROR too long request");
- }
- verbosePrint("%s() LN%d: Request:\n%s\n", __func__, __LINE__, request_buf);
-
- req_str_len = strlen(request_buf);
- sent = 0;
- do {
-#ifdef WINDOWS
- bytes = send(sockfd, request_buf + sent, req_str_len - sent, 0);
-#else
- bytes = write(sockfd, request_buf + sent, req_str_len - sent);
-#endif
- if (bytes < 0)
- ERROR_EXIT("ERROR writing message to socket");
- if (bytes == 0)
- break;
- sent+=bytes;
- } while(sent < req_str_len);
-
- memset(response_buf, 0, RESP_BUF_LEN);
- resp_len = sizeof(response_buf) - 1;
- received = 0;
- do {
-#ifdef WINDOWS
- bytes = recv(sockfd, response_buf + received, resp_len - received, 0);
-#else
- bytes = read(sockfd, response_buf + received, resp_len - received);
-#endif
- if (bytes < 0) {
- free(request_buf);
- ERROR_EXIT("ERROR reading response from socket");
- }
- if (bytes == 0)
- break;
- received += bytes;
- } while(received < resp_len);
-
- if (received == resp_len) {
- free(request_buf);
- ERROR_EXIT("ERROR storing complete response from socket");
- }
-
- response_buf[RESP_BUF_LEN - 1] = '\0';
- printf("Response:\n%s\n", response_buf);
-
+ debugPrint("%s() LN%d, sockfd=%d\n", __func__, __LINE__, sockfd);
free(request_buf);
+ ERROR_EXIT("ERROR opening socket");
+ }
+
+ server = gethostbyname(host);
+ if (server == NULL) {
+ free(request_buf);
+ ERROR_EXIT("ERROR, no such host");
+ }
+
+ debugPrint("h_name: %s\nh_addretype: %s\nh_length: %d\n",
+ server->h_name,
+ (server->h_addrtype == AF_INET)?"ipv4":"ipv6",
+ server->h_length);
+
+ memset(&serv_addr, 0, sizeof(serv_addr));
+ serv_addr.sin_family = AF_INET;
+ serv_addr.sin_port = htons(rest_port);
#ifdef WINDOWS
- closesocket(sockfd);
+ serv_addr.sin_addr.s_addr = inet_addr(host);
+#else
+ memcpy(&serv_addr.sin_addr.s_addr,server->h_addr,server->h_length);
+#endif
+
+ int retConn = connect(sockfd,(struct sockaddr *)&serv_addr,sizeof(serv_addr));
+ debugPrint("%s() LN%d connect() return %d\n", __func__, __LINE__, retConn);
+ if (retConn < 0) {
+ free(request_buf);
+ ERROR_EXIT("ERROR connecting");
+ }
+
+ memset(base64_buf, 0, INPUT_BUF_LEN);
+
+ for (int n = 0, m = 0; n < userpass_buf_len;) {
+ uint32_t oct_a = n < userpass_buf_len ?
+ (unsigned char) userpass_buf[n++]:0;
+ uint32_t oct_b = n < userpass_buf_len ?
+ (unsigned char) userpass_buf[n++]:0;
+ uint32_t oct_c = n < userpass_buf_len ?
+ (unsigned char) userpass_buf[n++]:0;
+ uint32_t triple = (oct_a << 0x10) + (oct_b << 0x08) + oct_c;
+
+ base64_buf[m++] = base64[(triple >> 3* 6) & 0x3f];
+ base64_buf[m++] = base64[(triple >> 2* 6) & 0x3f];
+ base64_buf[m++] = base64[(triple >> 1* 6) & 0x3f];
+ base64_buf[m++] = base64[(triple >> 0* 6) & 0x3f];
+ }
+
+ for (int l = 0; l < mod_table[userpass_buf_len % 3]; l++)
+ base64_buf[encoded_len - 1 - l] = '=';
+
+ debugPrint("%s() LN%d: auth string base64 encoded: %s\n",
+ __func__, __LINE__, base64_buf);
+ char *auth = base64_buf;
+
+ int r = snprintf(request_buf,
+ req_buf_len,
+ req_fmt, url, host, rest_port,
+ auth, strlen(sqlstr), sqlstr);
+ if (r >= req_buf_len) {
+ free(request_buf);
+ ERROR_EXIT("ERROR too long request");
+ }
+ verbosePrint("%s() LN%d: Request:\n%s\n", __func__, __LINE__, request_buf);
+
+ req_str_len = strlen(request_buf);
+ sent = 0;
+ do {
+#ifdef WINDOWS
+ bytes = send(sockfd, request_buf + sent, req_str_len - sent, 0);
+#else
+ bytes = write(sockfd, request_buf + sent, req_str_len - sent);
+#endif
+ if (bytes < 0)
+ ERROR_EXIT("ERROR writing message to socket");
+ if (bytes == 0)
+ break;
+ sent+=bytes;
+ } while(sent < req_str_len);
+
+ memset(response_buf, 0, RESP_BUF_LEN);
+ resp_len = sizeof(response_buf) - 1;
+ received = 0;
+ do {
+#ifdef WINDOWS
+ bytes = recv(sockfd, response_buf + received, resp_len - received, 0);
+#else
+ bytes = read(sockfd, response_buf + received, resp_len - received);
+#endif
+ if (bytes < 0) {
+ free(request_buf);
+ ERROR_EXIT("ERROR reading response from socket");
+ }
+ if (bytes == 0)
+ break;
+ received += bytes;
+ } while(received < resp_len);
+
+ if (received == resp_len) {
+ free(request_buf);
+ ERROR_EXIT("ERROR storing complete response from socket");
+ }
+
+ response_buf[RESP_BUF_LEN - 1] = '\0';
+ printf("Response:\n%s\n", response_buf);
+
+ free(request_buf);
+#ifdef WINDOWS
+ closesocket(sockfd);
WSACleanup();
#else
- close(sockfd);
+ close(sockfd);
#endif
- return 0;
+ return 0;
}
static char* getTagValueFromTagSample(SSuperTable* stbInfo, int tagUsePos) {
char* dataBuf = (char*)calloc(TSDB_MAX_SQL_LEN+1, 1);
if (NULL == dataBuf) {
errorPrint("%s() LN%d, calloc failed! size:%d\n",
- __func__, __LINE__, TSDB_MAX_SQL_LEN+1);
+ __func__, __LINE__, TSDB_MAX_SQL_LEN+1);
return NULL;
}
int dataLen = 0;
dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen,
- "(%s)", stbInfo->tagDataBuf + stbInfo->lenOfTagOfOneRow * tagUsePos);
+ "(%s)", stbInfo->tagDataBuf + stbInfo->lenOfTagOfOneRow * tagUsePos);
return dataBuf;
}
@@ -2008,10 +2137,10 @@ static char* generateTagVaulesForStb(SSuperTable* stbInfo, int32_t tableSeq) {
dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen, "(");
for (int i = 0; i < stbInfo->tagCount; i++) {
if ((0 == strncasecmp(stbInfo->tags[i].dataType, "binary", strlen("binary")))
- || (0 == strncasecmp(stbInfo->tags[i].dataType, "nchar", strlen("nchar")))) {
+ || (0 == strncasecmp(stbInfo->tags[i].dataType, "nchar", strlen("nchar")))) {
if (stbInfo->tags[i].dataLen > TSDB_MAX_BINARY_LEN) {
printf("binary or nchar length overflow, max size:%u\n",
- (uint32_t)TSDB_MAX_BINARY_LEN);
+ (uint32_t)TSDB_MAX_BINARY_LEN);
tmfree(dataBuf);
return NULL;
}
@@ -2031,40 +2160,40 @@ static char* generateTagVaulesForStb(SSuperTable* stbInfo, int32_t tableSeq) {
}
//rand_string(buf, stbInfo->tags[i].dataLen);
dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen,
- "\'%s\', ", buf);
+ "\'%s\', ", buf);
tmfree(buf);
} else if (0 == strncasecmp(stbInfo->tags[i].dataType,
- "int", strlen("int"))) {
+ "int", strlen("int"))) {
dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen,
- "%d, ", tableSeq);
+ "%d, ", tableSeq);
} else if (0 == strncasecmp(stbInfo->tags[i].dataType,
- "bigint", strlen("bigint"))) {
+ "bigint", strlen("bigint"))) {
dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen,
- "%"PRId64", ", rand_bigint());
+ "%"PRId64", ", rand_bigint());
} else if (0 == strncasecmp(stbInfo->tags[i].dataType,
- "float", strlen("float"))) {
+ "float", strlen("float"))) {
dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen,
- "%f, ", rand_float());
+ "%f, ", rand_float());
} else if (0 == strncasecmp(stbInfo->tags[i].dataType,
- "double", strlen("double"))) {
+ "double", strlen("double"))) {
dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen,
- "%f, ", rand_double());
+ "%f, ", rand_double());
} else if (0 == strncasecmp(stbInfo->tags[i].dataType,
- "smallint", strlen("smallint"))) {
+ "smallint", strlen("smallint"))) {
dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen,
- "%d, ", rand_smallint());
+ "%d, ", rand_smallint());
} else if (0 == strncasecmp(stbInfo->tags[i].dataType,
- "tinyint", strlen("tinyint"))) {
+ "tinyint", strlen("tinyint"))) {
dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen,
- "%d, ", rand_tinyint());
+ "%d, ", rand_tinyint());
} else if (0 == strncasecmp(stbInfo->tags[i].dataType,
- "bool", strlen("bool"))) {
+ "bool", strlen("bool"))) {
dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen,
- "%d, ", rand_bool());
+ "%d, ", rand_bool());
} else if (0 == strncasecmp(stbInfo->tags[i].dataType,
- "timestamp", strlen("timestamp"))) {
+ "timestamp", strlen("timestamp"))) {
dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen,
- "%"PRId64", ", rand_bigint());
+ "%"PRId64", ", rand_bigint());
} else {
printf("No support data type: %s\n", stbInfo->tags[i].dataType);
tmfree(dataBuf);
@@ -2148,8 +2277,8 @@ static int calcRowLen(SSuperTable* superTbls) {
static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
- char* dbName, char* sTblName, char** childTblNameOfSuperTbl,
- int* childTblCountOfSuperTbl, int limit, int offset) {
+ char* dbName, char* sTblName, char** childTblNameOfSuperTbl,
+ int* childTblCountOfSuperTbl, int limit, int offset) {
char command[BUFFER_SIZE] = "\0";
char limitBuf[100] = "\0";
@@ -2165,7 +2294,7 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
//get all child table name use cmd: select tbname from superTblName;
snprintf(command, BUFFER_SIZE, "select tbname from %s.%s %s",
- dbName, sTblName, limitBuf);
+ dbName, sTblName, limitBuf);
res = taos_query(taos, command);
int32_t code = taos_errno(res);
@@ -2173,7 +2302,7 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
taos_free_result(res);
taos_close(taos);
errorPrint("%s() LN%d, failed to run command %s\n",
- __func__, __LINE__, command);
+ __func__, __LINE__, command);
exit(-1);
}
@@ -2182,10 +2311,10 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
if (childTblName == NULL) {
childTblName = (char*)calloc(1, childTblCount * TSDB_TABLE_NAME_LEN);
if (NULL == childTblName) {
- taos_free_result(res);
- taos_close(taos);
- errorPrint("%s() LN%d, failed to allocate memory!\n", __func__, __LINE__);
- exit(-1);
+ taos_free_result(res);
+ taos_close(taos);
+ errorPrint("%s() LN%d, failed to allocate memory!\n", __func__, __LINE__);
+ exit(-1);
}
}
@@ -2197,16 +2326,16 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
count++;
if (count >= childTblCount - 1) {
char *tmp = realloc(childTblName,
- (size_t)childTblCount*1.5*TSDB_TABLE_NAME_LEN+1);
+ (size_t)childTblCount*1.5*TSDB_TABLE_NAME_LEN+1);
if (tmp != NULL) {
childTblName = tmp;
childTblCount = (int)(childTblCount*1.5);
memset(childTblName + count*TSDB_TABLE_NAME_LEN, 0,
- (size_t)((childTblCount-count)*TSDB_TABLE_NAME_LEN));
+ (size_t)((childTblCount-count)*TSDB_TABLE_NAME_LEN));
} else {
// exit, if allocate more memory failed
errorPrint("%s() LN%d, realloc fail for save child table name of %s.%s\n",
- __func__, __LINE__, dbName, sTblName);
+ __func__, __LINE__, dbName, sTblName);
tmfree(childTblName);
taos_free_result(res);
taos_close(taos);
@@ -2224,16 +2353,16 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
}
static int getAllChildNameOfSuperTable(TAOS * taos, char* dbName,
- char* sTblName, char** childTblNameOfSuperTbl,
- int* childTblCountOfSuperTbl) {
+ char* sTblName, char** childTblNameOfSuperTbl,
+ int* childTblCountOfSuperTbl) {
- return getChildNameOfSuperTableWithLimitAndOffset(taos, dbName, sTblName,
- childTblNameOfSuperTbl, childTblCountOfSuperTbl,
- -1, -1);
+ return getChildNameOfSuperTableWithLimitAndOffset(taos, dbName, sTblName,
+ childTblNameOfSuperTbl, childTblCountOfSuperTbl,
+ -1, -1);
}
static int getSuperTableFromServer(TAOS * taos, char* dbName,
- SSuperTable* superTbls) {
+ SSuperTable* superTbls) {
char command[BUFFER_SIZE] = "\0";
TAOS_RES * res;
@@ -2261,29 +2390,29 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName,
if (strcmp((char *)row[TSDB_DESCRIBE_METRIC_NOTE_INDEX], "TAG") == 0) {
tstrncpy(superTbls->tags[tagIndex].field,
- (char *)row[TSDB_DESCRIBE_METRIC_FIELD_INDEX],
- fields[TSDB_DESCRIBE_METRIC_FIELD_INDEX].bytes);
+ (char *)row[TSDB_DESCRIBE_METRIC_FIELD_INDEX],
+ fields[TSDB_DESCRIBE_METRIC_FIELD_INDEX].bytes);
tstrncpy(superTbls->tags[tagIndex].dataType,
- (char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
- fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes);
+ (char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
+ fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes);
superTbls->tags[tagIndex].dataLen =
*((int *)row[TSDB_DESCRIBE_METRIC_LENGTH_INDEX]);
tstrncpy(superTbls->tags[tagIndex].note,
- (char *)row[TSDB_DESCRIBE_METRIC_NOTE_INDEX],
- fields[TSDB_DESCRIBE_METRIC_NOTE_INDEX].bytes);
+ (char *)row[TSDB_DESCRIBE_METRIC_NOTE_INDEX],
+ fields[TSDB_DESCRIBE_METRIC_NOTE_INDEX].bytes);
tagIndex++;
} else {
tstrncpy(superTbls->columns[columnIndex].field,
- (char *)row[TSDB_DESCRIBE_METRIC_FIELD_INDEX],
- fields[TSDB_DESCRIBE_METRIC_FIELD_INDEX].bytes);
+ (char *)row[TSDB_DESCRIBE_METRIC_FIELD_INDEX],
+ fields[TSDB_DESCRIBE_METRIC_FIELD_INDEX].bytes);
tstrncpy(superTbls->columns[columnIndex].dataType,
- (char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
- fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes);
+ (char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
+ fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes);
superTbls->columns[columnIndex].dataLen =
*((int *)row[TSDB_DESCRIBE_METRIC_LENGTH_INDEX]);
tstrncpy(superTbls->columns[columnIndex].note,
- (char *)row[TSDB_DESCRIBE_METRIC_NOTE_INDEX],
- fields[TSDB_DESCRIBE_METRIC_NOTE_INDEX].bytes);
+ (char *)row[TSDB_DESCRIBE_METRIC_NOTE_INDEX],
+ fields[TSDB_DESCRIBE_METRIC_NOTE_INDEX].bytes);
columnIndex++;
}
count++;
@@ -2313,8 +2442,10 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName,
return 0;
}
-static int createSuperTable(TAOS * taos, char* dbName,
- SSuperTable* superTbl) {
+static int createSuperTable(
+ TAOS * taos, char* dbName,
+ SSuperTable* superTbl) {
+
char command[BUFFER_SIZE] = "\0";
char cols[STRING_LEN] = "\0";
@@ -2325,7 +2456,7 @@ static int createSuperTable(TAOS * taos, char* dbName,
if (superTbl->columnCount == 0) {
errorPrint("%s() LN%d, super table column count is %d\n",
- __func__, __LINE__, superTbl->columnCount);
+ __func__, __LINE__, superTbl->columnCount);
return -1;
}
@@ -2334,13 +2465,13 @@ static int createSuperTable(TAOS * taos, char* dbName,
if (strcasecmp(dataType, "BINARY") == 0) {
len += snprintf(cols + len, STRING_LEN - len,
- ", col%d %s(%d)", colIndex, "BINARY",
- superTbl->columns[colIndex].dataLen);
+ ", col%d %s(%d)", colIndex, "BINARY",
+ superTbl->columns[colIndex].dataLen);
lenOfOneRow += superTbl->columns[colIndex].dataLen + 3;
} else if (strcasecmp(dataType, "NCHAR") == 0) {
len += snprintf(cols + len, STRING_LEN - len,
- ", col%d %s(%d)", colIndex, "NCHAR",
- superTbl->columns[colIndex].dataLen);
+ ", col%d %s(%d)", colIndex, "NCHAR",
+ superTbl->columns[colIndex].dataLen);
lenOfOneRow += superTbl->columns[colIndex].dataLen + 3;
} else if (strcasecmp(dataType, "INT") == 0) {
len += snprintf(cols + len, STRING_LEN - len, ", col%d %s", colIndex, "INT");
@@ -2369,7 +2500,7 @@ static int createSuperTable(TAOS * taos, char* dbName,
} else {
taos_close(taos);
errorPrint("%s() LN%d, config error data type : %s\n",
- __func__, __LINE__, dataType);
+ __func__, __LINE__, dataType);
exit(-1);
}
}
@@ -2381,18 +2512,18 @@ static int createSuperTable(TAOS * taos, char* dbName,
superTbl->colsOfCreateChildTable = (char*)calloc(len+20, 1);
if (NULL == superTbl->colsOfCreateChildTable) {
errorPrint("%s() LN%d, Failed when calloc, size:%d",
- __func__, __LINE__, len+1);
+ __func__, __LINE__, len+1);
taos_close(taos);
exit(-1);
}
snprintf(superTbl->colsOfCreateChildTable, len+20, "(ts timestamp%s)", cols);
verbosePrint("%s() LN%d: %s\n",
- __func__, __LINE__, superTbl->colsOfCreateChildTable);
+ __func__, __LINE__, superTbl->colsOfCreateChildTable);
if (superTbl->tagCount == 0) {
errorPrint("%s() LN%d, super table tag count is %d\n",
- __func__, __LINE__, superTbl->tagCount);
+ __func__, __LINE__, superTbl->tagCount);
return -1;
}
@@ -2407,44 +2538,44 @@ static int createSuperTable(TAOS * taos, char* dbName,
if (strcasecmp(dataType, "BINARY") == 0) {
len += snprintf(tags + len, STRING_LEN - len, "t%d %s(%d), ", tagIndex,
- "BINARY", superTbl->tags[tagIndex].dataLen);
+ "BINARY", superTbl->tags[tagIndex].dataLen);
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 3;
} else if (strcasecmp(dataType, "NCHAR") == 0) {
len += snprintf(tags + len, STRING_LEN - len, "t%d %s(%d), ", tagIndex,
- "NCHAR", superTbl->tags[tagIndex].dataLen);
+ "NCHAR", superTbl->tags[tagIndex].dataLen);
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 3;
} else if (strcasecmp(dataType, "INT") == 0) {
len += snprintf(tags + len, STRING_LEN - len, "t%d %s, ", tagIndex,
- "INT");
+ "INT");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 11;
} else if (strcasecmp(dataType, "BIGINT") == 0) {
len += snprintf(tags + len, STRING_LEN - len, "t%d %s, ", tagIndex,
- "BIGINT");
+ "BIGINT");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 21;
} else if (strcasecmp(dataType, "SMALLINT") == 0) {
len += snprintf(tags + len, STRING_LEN - len, "t%d %s, ", tagIndex,
- "SMALLINT");
+ "SMALLINT");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 6;
} else if (strcasecmp(dataType, "TINYINT") == 0) {
len += snprintf(tags + len, STRING_LEN - len, "t%d %s, ", tagIndex,
- "TINYINT");
+ "TINYINT");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 4;
} else if (strcasecmp(dataType, "BOOL") == 0) {
len += snprintf(tags + len, STRING_LEN - len, "t%d %s, ", tagIndex,
- "BOOL");
+ "BOOL");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 6;
} else if (strcasecmp(dataType, "FLOAT") == 0) {
len += snprintf(tags + len, STRING_LEN - len, "t%d %s, ", tagIndex,
- "FLOAT");
+ "FLOAT");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 22;
} else if (strcasecmp(dataType, "DOUBLE") == 0) {
len += snprintf(tags + len, STRING_LEN - len, "t%d %s, ", tagIndex,
- "DOUBLE");
+ "DOUBLE");
lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 42;
} else {
taos_close(taos);
errorPrint("%s() LN%d, config error tag type : %s\n",
- __func__, __LINE__, dataType);
+ __func__, __LINE__, dataType);
exit(-1);
}
}
@@ -2455,14 +2586,14 @@ static int createSuperTable(TAOS * taos, char* dbName,
superTbl->lenOfTagOfOneRow = lenOfTagOfOneRow;
snprintf(command, BUFFER_SIZE,
- "create table if not exists %s.%s (ts timestamp%s) tags %s",
- dbName, superTbl->sTblName, cols, tags);
+ "create table if not exists %s.%s (ts timestamp%s) tags %s",
+ dbName, superTbl->sTblName, cols, tags);
verbosePrint("%s() LN%d: %s\n", __func__, __LINE__, command);
if (0 != queryDbExec(taos, command, NO_INSERT_TYPE, false)) {
- errorPrint( "create supertable %s failed!\n\n",
- superTbl->sTblName);
- return -1;
+ errorPrint( "create supertable %s failed!\n\n",
+ superTbl->sTblName);
+ return -1;
}
debugPrint("create supertable %s success!\n\n", superTbl->sTblName);
return 0;
@@ -2489,35 +2620,35 @@ static int createDatabasesAndStables() {
int dataLen = 0;
dataLen += snprintf(command + dataLen,
- BUFFER_SIZE - dataLen, "create database if not exists %s", g_Dbs.db[i].dbName);
+ BUFFER_SIZE - dataLen, "create database if not exists %s", g_Dbs.db[i].dbName);
if (g_Dbs.db[i].dbCfg.blocks > 0) {
dataLen += snprintf(command + dataLen,
- BUFFER_SIZE - dataLen, " blocks %d", g_Dbs.db[i].dbCfg.blocks);
+ BUFFER_SIZE - dataLen, " blocks %d", g_Dbs.db[i].dbCfg.blocks);
}
if (g_Dbs.db[i].dbCfg.cache > 0) {
dataLen += snprintf(command + dataLen,
- BUFFER_SIZE - dataLen, " cache %d", g_Dbs.db[i].dbCfg.cache);
+ BUFFER_SIZE - dataLen, " cache %d", g_Dbs.db[i].dbCfg.cache);
}
if (g_Dbs.db[i].dbCfg.days > 0) {
dataLen += snprintf(command + dataLen,
- BUFFER_SIZE - dataLen, " days %d", g_Dbs.db[i].dbCfg.days);
+ BUFFER_SIZE - dataLen, " days %d", g_Dbs.db[i].dbCfg.days);
}
if (g_Dbs.db[i].dbCfg.keep > 0) {
dataLen += snprintf(command + dataLen,
- BUFFER_SIZE - dataLen, " keep %d", g_Dbs.db[i].dbCfg.keep);
+ BUFFER_SIZE - dataLen, " keep %d", g_Dbs.db[i].dbCfg.keep);
}
if (g_Dbs.db[i].dbCfg.quorum > 1) {
dataLen += snprintf(command + dataLen,
- BUFFER_SIZE - dataLen, " quorum %d", g_Dbs.db[i].dbCfg.quorum);
+ BUFFER_SIZE - dataLen, " quorum %d", g_Dbs.db[i].dbCfg.quorum);
}
if (g_Dbs.db[i].dbCfg.replica > 0) {
dataLen += snprintf(command + dataLen,
- BUFFER_SIZE - dataLen, " replica %d", g_Dbs.db[i].dbCfg.replica);
+ BUFFER_SIZE - dataLen, " replica %d", g_Dbs.db[i].dbCfg.replica);
}
if (g_Dbs.db[i].dbCfg.update > 0) {
dataLen += snprintf(command + dataLen,
- BUFFER_SIZE - dataLen, " update %d", g_Dbs.db[i].dbCfg.update);
+ BUFFER_SIZE - dataLen, " update %d", g_Dbs.db[i].dbCfg.update);
}
//if (g_Dbs.db[i].dbCfg.maxtablesPerVnode > 0) {
// dataLen += snprintf(command + dataLen,
@@ -2525,33 +2656,33 @@ static int createDatabasesAndStables() {
//}
if (g_Dbs.db[i].dbCfg.minRows > 0) {
dataLen += snprintf(command + dataLen,
- BUFFER_SIZE - dataLen, " minrows %d", g_Dbs.db[i].dbCfg.minRows);
+ BUFFER_SIZE - dataLen, " minrows %d", g_Dbs.db[i].dbCfg.minRows);
}
if (g_Dbs.db[i].dbCfg.maxRows > 0) {
dataLen += snprintf(command + dataLen,
- BUFFER_SIZE - dataLen, " maxrows %d", g_Dbs.db[i].dbCfg.maxRows);
+ BUFFER_SIZE - dataLen, " maxrows %d", g_Dbs.db[i].dbCfg.maxRows);
}
if (g_Dbs.db[i].dbCfg.comp > 0) {
dataLen += snprintf(command + dataLen,
- BUFFER_SIZE - dataLen, " comp %d", g_Dbs.db[i].dbCfg.comp);
+ BUFFER_SIZE - dataLen, " comp %d", g_Dbs.db[i].dbCfg.comp);
}
if (g_Dbs.db[i].dbCfg.walLevel > 0) {
dataLen += snprintf(command + dataLen,
- BUFFER_SIZE - dataLen, " wal %d", g_Dbs.db[i].dbCfg.walLevel);
+ BUFFER_SIZE - dataLen, " wal %d", g_Dbs.db[i].dbCfg.walLevel);
}
if (g_Dbs.db[i].dbCfg.cacheLast > 0) {
dataLen += snprintf(command + dataLen,
- BUFFER_SIZE - dataLen, " cachelast %d", g_Dbs.db[i].dbCfg.cacheLast);
+ BUFFER_SIZE - dataLen, " cachelast %d", g_Dbs.db[i].dbCfg.cacheLast);
}
if (g_Dbs.db[i].dbCfg.fsync > 0) {
dataLen += snprintf(command + dataLen, BUFFER_SIZE - dataLen,
- " fsync %d", g_Dbs.db[i].dbCfg.fsync);
+ " fsync %d", g_Dbs.db[i].dbCfg.fsync);
}
if ((0 == strncasecmp(g_Dbs.db[i].dbCfg.precision, "ms", strlen("ms")))
- || (0 == strncasecmp(g_Dbs.db[i].dbCfg.precision,
- "us", strlen("us")))) {
+ || (0 == strncasecmp(g_Dbs.db[i].dbCfg.precision,
+ "us", strlen("us")))) {
dataLen += snprintf(command + dataLen, BUFFER_SIZE - dataLen,
- " precision \'%s\';", g_Dbs.db[i].dbCfg.precision);
+ " precision \'%s\';", g_Dbs.db[i].dbCfg.precision);
}
debugPrint("%s() %d command: %s\n", __func__, __LINE__, command);
@@ -2564,7 +2695,7 @@ static int createDatabasesAndStables() {
}
debugPrint("%s() %d supertbl count:%d\n",
- __func__, __LINE__, g_Dbs.db[i].superTblCount);
+ __func__, __LINE__, g_Dbs.db[i].superTblCount);
int validStbCount = 0;
@@ -2577,7 +2708,7 @@ static int createDatabasesAndStables() {
if ((ret != 0) || (g_Dbs.db[i].drop)) {
ret = createSuperTable(taos, g_Dbs.db[i].dbName,
- &g_Dbs.db[i].superTbls[j]);
+ &g_Dbs.db[i].superTbls[j]);
if (0 != ret) {
errorPrint("create super table %d failed!\n\n", j);
@@ -2586,10 +2717,10 @@ static int createDatabasesAndStables() {
}
ret = getSuperTableFromServer(taos, g_Dbs.db[i].dbName,
- &g_Dbs.db[i].superTbls[j]);
+ &g_Dbs.db[i].superTbls[j]);
if (0 != ret) {
errorPrint("\nget super table %s.%s info failed!\n\n",
- g_Dbs.db[i].dbName, g_Dbs.db[i].superTbls[j].sTblName);
+ g_Dbs.db[i].dbName, g_Dbs.db[i].superTbls[j].sTblName);
continue;
}
@@ -2623,20 +2754,20 @@ static void* createTable(void *sarg)
int batchNum = 0;
verbosePrint("%s() LN%d: Creating table from %d to %d\n",
- __func__, __LINE__,
- pThreadInfo->start_table_from, pThreadInfo->end_table_to);
+ __func__, __LINE__,
+ pThreadInfo->start_table_from, pThreadInfo->end_table_to);
for (int i = pThreadInfo->start_table_from; i <= pThreadInfo->end_table_to; i++) {
if (0 == g_Dbs.use_metric) {
snprintf(buffer, buff_len,
- "create table if not exists %s.%s%d %s;",
- pThreadInfo->db_name,
- g_args.tb_prefix, i,
- pThreadInfo->cols);
+ "create table if not exists %s.%s%d %s;",
+ pThreadInfo->db_name,
+ g_args.tb_prefix, i,
+ pThreadInfo->cols);
} else {
if (superTblInfo == NULL) {
errorPrint("%s() LN%d, use metric, but super table info is NULL\n",
- __func__, __LINE__);
+ __func__, __LINE__);
free(buffer);
exit(-1);
} else {
@@ -2644,31 +2775,31 @@ static void* createTable(void *sarg)
batchNum = 0;
memset(buffer, 0, buff_len);
len += snprintf(buffer + len,
- buff_len - len, "create table ");
+ buff_len - len, "create table ");
}
char* tagsValBuf = NULL;
if (0 == superTblInfo->tagSource) {
tagsValBuf = generateTagVaulesForStb(superTblInfo, i);
} else {
tagsValBuf = getTagValueFromTagSample(
- superTblInfo,
- i % superTblInfo->tagSampleCount);
+ superTblInfo,
+ i % superTblInfo->tagSampleCount);
}
if (NULL == tagsValBuf) {
free(buffer);
return NULL;
}
len += snprintf(buffer + len,
- buff_len - len,
- "if not exists %s.%s%d using %s.%s tags %s ",
- pThreadInfo->db_name, superTblInfo->childTblPrefix,
- i, pThreadInfo->db_name,
- superTblInfo->sTblName, tagsValBuf);
+ buff_len - len,
+ "if not exists %s.%s%d using %s.%s tags %s ",
+ pThreadInfo->db_name, superTblInfo->childTblPrefix,
+ i, pThreadInfo->db_name,
+ superTblInfo->sTblName, tagsValBuf);
free(tagsValBuf);
batchNum++;
if ((batchNum < superTblInfo->batchCreateTableNum)
- && ((buff_len - len)
- >= (superTblInfo->lenOfTagOfOneRow + 256))) {
+ && ((buff_len - len)
+ >= (superTblInfo->lenOfTagOfOneRow + 256))) {
continue;
}
}
@@ -2685,7 +2816,7 @@ static void* createTable(void *sarg)
int64_t currentPrintTime = taosGetTimestampMs();
if (currentPrintTime - lastPrintTime > 30*1000) {
printf("thread[%d] already create %d - %d tables\n",
- pThreadInfo->threadID, pThreadInfo->start_table_from, i);
+ pThreadInfo->threadID, pThreadInfo->start_table_from, i);
lastPrintTime = currentPrintTime;
}
}
@@ -2702,8 +2833,8 @@ static void* createTable(void *sarg)
}
static int startMultiThreadCreateChildTable(
- char* cols, int threads, int startFrom, int ntables,
- char* db_name, SSuperTable* superTblInfo) {
+ char* cols, int threads, int startFrom, int ntables,
+ char* db_name, SSuperTable* superTblInfo) {
pthread_t *pids = malloc(threads * sizeof(pthread_t));
threadInfo *infos = malloc(threads * sizeof(threadInfo));
@@ -2733,14 +2864,14 @@ static int startMultiThreadCreateChildTable(
t_info->superTblInfo = superTblInfo;
verbosePrint("%s() %d db_name: %s\n", __func__, __LINE__, db_name);
t_info->taos = taos_connect(
- g_Dbs.host,
- g_Dbs.user,
- g_Dbs.password,
- db_name,
- g_Dbs.port);
+ g_Dbs.host,
+ g_Dbs.user,
+ g_Dbs.password,
+ db_name,
+ g_Dbs.port);
if (t_info->taos == NULL) {
errorPrint( "%s() LN%d, Failed to connect to TDengine, reason:%s\n",
- __func__, __LINE__, taos_errstr(NULL));
+ __func__, __LINE__, taos_errstr(NULL));
free(pids);
free(infos);
return -1;
@@ -2772,64 +2903,62 @@ static int startMultiThreadCreateChildTable(
}
static void createChildTables() {
- char tblColsBuf[MAX_SQL_SIZE];
- int len;
+ char tblColsBuf[MAX_SQL_SIZE];
+ int len;
for (int i = 0; i < g_Dbs.dbCount; i++) {
if (g_Dbs.use_metric) {
if (g_Dbs.db[i].superTblCount > 0) {
- // with super table
+ // with super table
for (int j = 0; j < g_Dbs.db[i].superTblCount; j++) {
if ((AUTO_CREATE_SUBTBL == g_Dbs.db[i].superTbls[j].autoCreateTable)
- || (TBL_ALREADY_EXISTS == g_Dbs.db[i].superTbls[j].childTblExists)) {
+ || (TBL_ALREADY_EXISTS == g_Dbs.db[i].superTbls[j].childTblExists)) {
continue;
}
verbosePrint("%s() LN%d: %s\n", __func__, __LINE__,
- g_Dbs.db[i].superTbls[j].colsOfCreateChildTable);
+ g_Dbs.db[i].superTbls[j].colsOfCreateChildTable);
int startFrom = 0;
g_totalChildTables += g_Dbs.db[i].superTbls[j].childTblCount;
verbosePrint("%s() LN%d: create %d child tables from %d\n",
- __func__, __LINE__, g_totalChildTables, startFrom);
+ __func__, __LINE__, g_totalChildTables, startFrom);
startMultiThreadCreateChildTable(
- g_Dbs.db[i].superTbls[j].colsOfCreateChildTable,
- g_Dbs.threadCountByCreateTbl,
- startFrom,
- g_Dbs.db[i].superTbls[j].childTblCount,
- g_Dbs.db[i].dbName, &(g_Dbs.db[i].superTbls[j]));
+ g_Dbs.db[i].superTbls[j].colsOfCreateChildTable,
+ g_Dbs.threadCountByCreateTbl,
+ startFrom,
+ g_Dbs.db[i].superTbls[j].childTblCount,
+ g_Dbs.db[i].dbName, &(g_Dbs.db[i].superTbls[j]));
}
}
} else {
// normal table
len = snprintf(tblColsBuf, MAX_SQL_SIZE, "(TS TIMESTAMP");
- int j = 0;
- while(g_args.datatype[j]) {
- if ((strncasecmp(g_args.datatype[j], "BINARY", strlen("BINARY")) == 0)
- || (strncasecmp(g_args.datatype[j],
- "NCHAR", strlen("NCHAR")) == 0)) {
- snprintf(tblColsBuf + len, MAX_SQL_SIZE - len,
- ", COL%d %s(60)", j, g_args.datatype[j]);
- } else {
- snprintf(tblColsBuf + len, MAX_SQL_SIZE - len,
- ", COL%d %s", j, g_args.datatype[j]);
- }
- len = strlen(tblColsBuf);
- j++;
+ for (int j = 0; j < g_args.num_of_CPR; j++) {
+ if ((strncasecmp(g_args.datatype[j], "BINARY", strlen("BINARY")) == 0)
+ || (strncasecmp(g_args.datatype[j],
+ "NCHAR", strlen("NCHAR")) == 0)) {
+ snprintf(tblColsBuf + len, MAX_SQL_SIZE - len,
+ ", COL%d %s(%d)", j, g_args.datatype[j], g_args.len_of_binary);
+ } else {
+ snprintf(tblColsBuf + len, MAX_SQL_SIZE - len,
+ ", COL%d %s", j, g_args.datatype[j]);
+ }
+ len = strlen(tblColsBuf);
}
snprintf(tblColsBuf + len, MAX_SQL_SIZE - len, ")");
verbosePrint("%s() LN%d: dbName: %s num of tb: %d schema: %s\n",
- __func__, __LINE__,
- g_Dbs.db[i].dbName, g_args.num_of_tables, tblColsBuf);
+ __func__, __LINE__,
+ g_Dbs.db[i].dbName, g_args.num_of_tables, tblColsBuf);
startMultiThreadCreateChildTable(
- tblColsBuf,
- g_Dbs.threadCountByCreateTbl,
- 0,
- g_args.num_of_tables,
- g_Dbs.db[i].dbName,
- NULL);
+ tblColsBuf,
+ g_Dbs.threadCountByCreateTbl,
+ 0,
+ g_args.num_of_tables,
+ g_Dbs.db[i].dbName,
+ NULL);
}
}
}
@@ -2845,7 +2974,7 @@ static int readTagFromCsvFileToMem(SSuperTable * superTblInfo) {
FILE *fp = fopen(superTblInfo->tagsFile, "r");
if (fp == NULL) {
printf("Failed to open tags file: %s, reason:%s\n",
- superTblInfo->tagsFile, strerror(errno));
+ superTblInfo->tagsFile, strerror(errno));
return -1;
}
@@ -2877,12 +3006,12 @@ static int readTagFromCsvFileToMem(SSuperTable * superTblInfo) {
if (count >= tagCount - 1) {
char *tmp = realloc(tagDataBuf,
- (size_t)tagCount*1.5*superTblInfo->lenOfTagOfOneRow);
+ (size_t)tagCount*1.5*superTblInfo->lenOfTagOfOneRow);
if (tmp != NULL) {
tagDataBuf = tmp;
tagCount = (int)(tagCount*1.5);
memset(tagDataBuf + count*superTblInfo->lenOfTagOfOneRow,
- 0, (size_t)((tagCount-count)*superTblInfo->lenOfTagOfOneRow));
+ 0, (size_t)((tagCount-count)*superTblInfo->lenOfTagOfOneRow));
} else {
// exit, if allocate more memory failed
printf("realloc fail for save tag val from %s\n", superTblInfo->tagsFile);
@@ -2911,7 +3040,7 @@ int readSampleFromJsonFileToMem(SSuperTable * superTblInfo) {
Read 10000 lines at most. If more than 10000 lines, continue to read after using
*/
static int readSampleFromCsvFileToMem(
- SSuperTable* superTblInfo) {
+ SSuperTable* superTblInfo) {
size_t n = 0;
ssize_t readLen = 0;
char * line = NULL;
@@ -2919,20 +3048,20 @@ static int readSampleFromCsvFileToMem(
FILE* fp = fopen(superTblInfo->sampleFile, "r");
if (fp == NULL) {
- errorPrint( "Failed to open sample file: %s, reason:%s\n",
- superTblInfo->sampleFile, strerror(errno));
- return -1;
+ errorPrint( "Failed to open sample file: %s, reason:%s\n",
+ superTblInfo->sampleFile, strerror(errno));
+ return -1;
}
assert(superTblInfo->sampleDataBuf);
memset(superTblInfo->sampleDataBuf, 0,
- MAX_SAMPLES_ONCE_FROM_FILE * superTblInfo->lenOfOneRow);
+ MAX_SAMPLES_ONCE_FROM_FILE * superTblInfo->lenOfOneRow);
while(1) {
readLen = tgetline(&line, &n, fp);
if (-1 == readLen) {
if(0 != fseek(fp, 0, SEEK_SET)) {
errorPrint( "Failed to fseek file: %s, reason:%s\n",
- superTblInfo->sampleFile, strerror(errno));
+ superTblInfo->sampleFile, strerror(errno));
fclose(fp);
return -1;
}
@@ -2949,12 +3078,12 @@ static int readSampleFromCsvFileToMem(
if (readLen > superTblInfo->lenOfOneRow) {
printf("sample row len[%d] overflow define schema len[%d], so discard this row\n",
- (int32_t)readLen, superTblInfo->lenOfOneRow);
+ (int32_t)readLen, superTblInfo->lenOfOneRow);
continue;
}
memcpy(superTblInfo->sampleDataBuf + getRows * superTblInfo->lenOfOneRow,
- line, readLen);
+ line, readLen);
getRows++;
if (getRows == MAX_SAMPLES_ONCE_FROM_FILE) {
@@ -2968,7 +3097,7 @@ static int readSampleFromCsvFileToMem(
}
static bool getColumnAndTagTypeFromInsertJsonFile(
- cJSON* stbInfo, SSuperTable* superTbls) {
+ cJSON* stbInfo, SSuperTable* superTbls) {
bool ret = false;
// columns
@@ -2985,7 +3114,7 @@ static bool getColumnAndTagTypeFromInsertJsonFile(
int columnSize = cJSON_GetArraySize(columns);
if ((columnSize + 1/* ts */) > MAX_COLUMN_COUNT) {
errorPrint("%s() LN%d, failed to read json, column size overflow, max column size is %d\n",
- __func__, __LINE__, MAX_COLUMN_COUNT);
+ __func__, __LINE__, MAX_COLUMN_COUNT);
goto PARSE_OVER;
}
@@ -3004,7 +3133,7 @@ static bool getColumnAndTagTypeFromInsertJsonFile(
count = countObj->valueint;
} else if (countObj && countObj->type != cJSON_Number) {
errorPrint("%s() LN%d, failed to read json, column count not found\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
} else {
count = 1;
@@ -3016,7 +3145,7 @@ static bool getColumnAndTagTypeFromInsertJsonFile(
if (!dataType || dataType->type != cJSON_String
|| dataType->valuestring == NULL) {
errorPrint("%s() LN%d: failed to read json, column type not found\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
//tstrncpy(superTbls->columns[k].dataType, dataType->valuestring, MAX_TB_NAME_SIZE);
@@ -3027,7 +3156,7 @@ static bool getColumnAndTagTypeFromInsertJsonFile(
columnCase.dataLen = dataLen->valueint;
} else if (dataLen && dataLen->type != cJSON_Number) {
debugPrint("%s() LN%d: failed to read json, column len not found\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
} else {
columnCase.dataLen = 8;
@@ -3035,7 +3164,7 @@ static bool getColumnAndTagTypeFromInsertJsonFile(
for (int n = 0; n < count; ++n) {
tstrncpy(superTbls->columns[index].dataType,
- columnCase.dataType, MAX_TB_NAME_SIZE);
+ columnCase.dataType, MAX_TB_NAME_SIZE);
superTbls->columns[index].dataLen = columnCase.dataLen;
index++;
}
@@ -3043,7 +3172,7 @@ static bool getColumnAndTagTypeFromInsertJsonFile(
if ((index + 1 /* ts */) > MAX_COLUMN_COUNT) {
errorPrint("%s() LN%d, failed to read json, column size overflow, allowed max column size is %d\n",
- __func__, __LINE__, MAX_COLUMN_COUNT);
+ __func__, __LINE__, MAX_COLUMN_COUNT);
goto PARSE_OVER;
}
@@ -3055,14 +3184,14 @@ static bool getColumnAndTagTypeFromInsertJsonFile(
cJSON *tags = cJSON_GetObjectItem(stbInfo, "tags");
if (!tags || tags->type != cJSON_Array) {
errorPrint("%s() LN%d, failed to read json, tags not found\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
int tagSize = cJSON_GetArraySize(tags);
if (tagSize > MAX_TAG_COUNT) {
errorPrint("%s() LN%d, failed to read json, tags size overflow, max tag size is %d\n",
- __func__, __LINE__, MAX_TAG_COUNT);
+ __func__, __LINE__, MAX_TAG_COUNT);
goto PARSE_OVER;
}
@@ -3088,7 +3217,7 @@ static bool getColumnAndTagTypeFromInsertJsonFile(
if (!dataType || dataType->type != cJSON_String
|| dataType->valuestring == NULL) {
errorPrint("%s() LN%d, failed to read json, tag type not found\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
tstrncpy(columnCase.dataType, dataType->valuestring, MAX_TB_NAME_SIZE);
@@ -3098,7 +3227,7 @@ static bool getColumnAndTagTypeFromInsertJsonFile(
columnCase.dataLen = dataLen->valueint;
} else if (dataLen && dataLen->type != cJSON_Number) {
errorPrint("%s() LN%d, failed to read json, column len not found\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
} else {
columnCase.dataLen = 0;
@@ -3106,7 +3235,7 @@ static bool getColumnAndTagTypeFromInsertJsonFile(
for (int n = 0; n < count; ++n) {
tstrncpy(superTbls->tags[index].dataType, columnCase.dataType,
- MAX_TB_NAME_SIZE);
+ MAX_TB_NAME_SIZE);
superTbls->tags[index].dataLen = columnCase.dataLen;
index++;
}
@@ -3114,7 +3243,7 @@ static bool getColumnAndTagTypeFromInsertJsonFile(
if (index > MAX_TAG_COUNT) {
errorPrint("%s() LN%d, failed to read json, tags size overflow, allowed max tag count is %d\n",
- __func__, __LINE__, MAX_TAG_COUNT);
+ __func__, __LINE__, MAX_TAG_COUNT);
goto PARSE_OVER;
}
@@ -3122,12 +3251,12 @@ static bool getColumnAndTagTypeFromInsertJsonFile(
if ((superTbls->columnCount + superTbls->tagCount + 1 /* ts */) > MAX_COLUMN_COUNT) {
errorPrint("%s() LN%d, columns + tags is more than allowed max columns count: %d\n",
- __func__, __LINE__, MAX_COLUMN_COUNT);
+ __func__, __LINE__, MAX_COLUMN_COUNT);
goto PARSE_OVER;
}
ret = true;
-PARSE_OVER:
+ PARSE_OVER:
return ret;
}
@@ -3194,7 +3323,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
g_Dbs.threadCountByCreateTbl = g_args.num_of_threads;
} else {
errorPrint("%s() LN%d, failed to read json, threads2 not found\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
@@ -3205,7 +3334,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
g_args.insert_interval = 0;
} else {
errorPrint("%s() LN%d, failed to read json, insert_interval input mistake\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
@@ -3216,9 +3345,9 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
// rows per table need be less than insert batch
if (g_args.interlace_rows > g_args.num_of_RPR) {
printf("NOTICE: interlace rows value %d > num_of_records_per_req %d\n\n",
- g_args.interlace_rows, g_args.num_of_RPR);
+ g_args.interlace_rows, g_args.num_of_RPR);
printf(" interlace rows value will be set to num_of_records_per_req %d\n\n",
- g_args.num_of_RPR);
+ g_args.num_of_RPR);
printf(" press Enter key to continue or Ctrl-C to stop.");
(void)getchar();
g_args.interlace_rows = g_args.num_of_RPR;
@@ -3227,7 +3356,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
g_args.interlace_rows = 0; // 0 means progressive mode, > 0 mean interlace mode. max value is less or equ num_of_records_per_req
} else {
errorPrint("%s() LN%d, failed to read json, interlace_rows input mistake\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
@@ -3235,10 +3364,10 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
if (maxSqlLen && maxSqlLen->type == cJSON_Number) {
g_args.max_sql_len = maxSqlLen->valueint;
} else if (!maxSqlLen) {
- g_args.max_sql_len = TSDB_PAYLOAD_SIZE;
+ g_args.max_sql_len = 1024000;
} else {
errorPrint("%s() LN%d, failed to read json, max_sql_len input mistake\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
@@ -3249,14 +3378,14 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
g_args.num_of_RPR = INT32_MAX;
} else {
errorPrint("%s() LN%d, failed to read json, num_of_records_per_req not found\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
cJSON *answerPrompt = cJSON_GetObjectItem(root, "confirm_parameter_prompt"); // yes, no,
if (answerPrompt
- && answerPrompt->type == cJSON_String
- && answerPrompt->valuestring != NULL) {
+ && answerPrompt->type == cJSON_String
+ && answerPrompt->valuestring != NULL) {
if (0 == strncasecmp(answerPrompt->valuestring, "yes", 3)) {
g_args.answer_yes = false;
} else if (0 == strncasecmp(answerPrompt->valuestring, "no", 2)) {
@@ -3280,8 +3409,8 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
int dbSize = cJSON_GetArraySize(dbs);
if (dbSize > MAX_DB_COUNT) {
errorPrint(
- "ERROR: failed to read json, databases size overflow, max database is %d\n",
- MAX_DB_COUNT);
+ "ERROR: failed to read json, databases size overflow, max database is %d\n",
+ MAX_DB_COUNT);
goto PARSE_OVER;
}
@@ -3315,15 +3444,15 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
g_Dbs.db[i].drop = g_args.drop_database;
} else {
errorPrint("%s() LN%d, failed to read json, drop input mistake\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
cJSON *precision = cJSON_GetObjectItem(dbinfo, "precision");
if (precision && precision->type == cJSON_String
- && precision->valuestring != NULL) {
+ && precision->valuestring != NULL) {
tstrncpy(g_Dbs.db[i].dbCfg.precision, precision->valuestring,
- MAX_DB_NAME_SIZE);
+ MAX_DB_NAME_SIZE);
} else if (!precision) {
//tstrncpy(g_Dbs.db[i].dbCfg.precision, "ms", MAX_DB_NAME_SIZE);
memset(g_Dbs.db[i].dbCfg.precision, 0, MAX_DB_NAME_SIZE);
@@ -3358,8 +3487,8 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
} else if (!keep) {
g_Dbs.db[i].dbCfg.keep = -1;
} else {
- printf("ERROR: failed to read json, keep not found\n");
- goto PARSE_OVER;
+ printf("ERROR: failed to read json, keep not found\n");
+ goto PARSE_OVER;
}
cJSON* days = cJSON_GetObjectItem(dbinfo, "days");
@@ -3368,8 +3497,8 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
} else if (!days) {
g_Dbs.db[i].dbCfg.days = -1;
} else {
- printf("ERROR: failed to read json, days not found\n");
- goto PARSE_OVER;
+ printf("ERROR: failed to read json, days not found\n");
+ goto PARSE_OVER;
}
cJSON* cache = cJSON_GetObjectItem(dbinfo, "cache");
@@ -3378,8 +3507,8 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
} else if (!cache) {
g_Dbs.db[i].dbCfg.cache = -1;
} else {
- printf("ERROR: failed to read json, cache not found\n");
- goto PARSE_OVER;
+ printf("ERROR: failed to read json, cache not found\n");
+ goto PARSE_OVER;
}
cJSON* blocks= cJSON_GetObjectItem(dbinfo, "blocks");
@@ -3388,8 +3517,8 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
} else if (!blocks) {
g_Dbs.db[i].dbCfg.blocks = -1;
} else {
- printf("ERROR: failed to read json, block not found\n");
- goto PARSE_OVER;
+ printf("ERROR: failed to read json, block not found\n");
+ goto PARSE_OVER;
}
//cJSON* maxtablesPerVnode= cJSON_GetObjectItem(dbinfo, "maxtablesPerVnode");
@@ -3408,8 +3537,8 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
} else if (!minRows) {
g_Dbs.db[i].dbCfg.minRows = -1;
} else {
- printf("ERROR: failed to read json, minRows not found\n");
- goto PARSE_OVER;
+ printf("ERROR: failed to read json, minRows not found\n");
+ goto PARSE_OVER;
}
cJSON* maxRows= cJSON_GetObjectItem(dbinfo, "maxRows");
@@ -3418,8 +3547,8 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
} else if (!maxRows) {
g_Dbs.db[i].dbCfg.maxRows = -1;
} else {
- printf("ERROR: failed to read json, maxRows not found\n");
- goto PARSE_OVER;
+ printf("ERROR: failed to read json, maxRows not found\n");
+ goto PARSE_OVER;
}
cJSON* comp= cJSON_GetObjectItem(dbinfo, "comp");
@@ -3428,8 +3557,8 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
} else if (!comp) {
g_Dbs.db[i].dbCfg.comp = -1;
} else {
- printf("ERROR: failed to read json, comp not found\n");
- goto PARSE_OVER;
+ printf("ERROR: failed to read json, comp not found\n");
+ goto PARSE_OVER;
}
cJSON* walLevel= cJSON_GetObjectItem(dbinfo, "walLevel");
@@ -3438,8 +3567,8 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
} else if (!walLevel) {
g_Dbs.db[i].dbCfg.walLevel = -1;
} else {
- printf("ERROR: failed to read json, walLevel not found\n");
- goto PARSE_OVER;
+ printf("ERROR: failed to read json, walLevel not found\n");
+ goto PARSE_OVER;
}
cJSON* cacheLast= cJSON_GetObjectItem(dbinfo, "cachelast");
@@ -3448,8 +3577,8 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
} else if (!cacheLast) {
g_Dbs.db[i].dbCfg.cacheLast = -1;
} else {
- printf("ERROR: failed to read json, cacheLast not found\n");
- goto PARSE_OVER;
+ printf("ERROR: failed to read json, cacheLast not found\n");
+ goto PARSE_OVER;
}
cJSON* quorum= cJSON_GetObjectItem(dbinfo, "quorum");
@@ -3458,8 +3587,8 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
} else if (!quorum) {
g_Dbs.db[i].dbCfg.quorum = 1;
} else {
- printf("failed to read json, quorum input mistake");
- goto PARSE_OVER;
+ printf("failed to read json, quorum input mistake");
+ goto PARSE_OVER;
}
cJSON* fsync= cJSON_GetObjectItem(dbinfo, "fsync");
@@ -3469,7 +3598,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
g_Dbs.db[i].dbCfg.fsync = -1;
} else {
errorPrint("%s() LN%d, failed to read json, fsync input mistake\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
@@ -3477,15 +3606,15 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
cJSON *stables = cJSON_GetObjectItem(dbinfos, "super_tables");
if (!stables || stables->type != cJSON_Array) {
errorPrint("%s() LN%d, failed to read json, super_tables not found\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
int stbSize = cJSON_GetArraySize(stables);
if (stbSize > MAX_SUPER_TABLE_COUNT) {
errorPrint(
- "%s() LN%d, failed to read json, supertable size overflow, max supertable is %d\n",
- __func__, __LINE__, MAX_SUPER_TABLE_COUNT);
+ "%s() LN%d, failed to read json, supertable size overflow, max supertable is %d\n",
+ __func__, __LINE__, MAX_SUPER_TABLE_COUNT);
goto PARSE_OVER;
}
@@ -3498,7 +3627,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
cJSON *stbName = cJSON_GetObjectItem(stbInfo, "name");
if (!stbName || stbName->type != cJSON_String || stbName->valuestring == NULL) {
errorPrint("%s() LN%d, failed to read json, stb name not found\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
tstrncpy(g_Dbs.db[i].superTbls[j].sTblName, stbName->valuestring, MAX_TB_NAME_SIZE);
@@ -3512,8 +3641,8 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
cJSON *autoCreateTbl = cJSON_GetObjectItem(stbInfo, "auto_create_table"); // yes, no, null
if (autoCreateTbl
- && autoCreateTbl->type == cJSON_String
- && autoCreateTbl->valuestring != NULL) {
+ && autoCreateTbl->type == cJSON_String
+ && autoCreateTbl->valuestring != NULL) {
if (0 == strncasecmp(autoCreateTbl->valuestring, "yes", 3)) {
g_Dbs.db[i].superTbls[j].autoCreateTable = AUTO_CREATE_SUBTBL;
} else if (0 == strncasecmp(autoCreateTbl->valuestring, "no", 2)) {
@@ -3528,6 +3657,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
goto PARSE_OVER;
}
+ /*
cJSON* batchCreateTbl = cJSON_GetObjectItem(stbInfo, "batch_create_tbl_num");
if (batchCreateTbl && batchCreateTbl->type == cJSON_Number) {
g_Dbs.db[i].superTbls[j].batchCreateTableNum = batchCreateTbl->valueint;
@@ -3537,16 +3667,17 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
printf("ERROR: failed to read json, batch_create_tbl_num not found\n");
goto PARSE_OVER;
}
+ */
cJSON *childTblExists = cJSON_GetObjectItem(stbInfo, "child_table_exists"); // yes, no
if (childTblExists
- && childTblExists->type == cJSON_String
- && childTblExists->valuestring != NULL) {
+ && childTblExists->type == cJSON_String
+ && childTblExists->valuestring != NULL) {
if ((0 == strncasecmp(childTblExists->valuestring, "yes", 3))
&& (g_Dbs.db[i].drop == false)) {
g_Dbs.db[i].superTbls[j].childTblExists = TBL_ALREADY_EXISTS;
} else if ((0 == strncasecmp(childTblExists->valuestring, "no", 2)
- || (g_Dbs.db[i].drop == true))) {
+ || (g_Dbs.db[i].drop == true))) {
g_Dbs.db[i].superTbls[j].childTblExists = TBL_NO_EXISTS;
} else {
g_Dbs.db[i].superTbls[j].childTblExists = TBL_NO_EXISTS;
@@ -3555,36 +3686,36 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
g_Dbs.db[i].superTbls[j].childTblExists = TBL_NO_EXISTS;
} else {
errorPrint("%s() LN%d, failed to read json, child_table_exists not found\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
cJSON* count = cJSON_GetObjectItem(stbInfo, "childtable_count");
if (!count || count->type != cJSON_Number || 0 >= count->valueint) {
errorPrint("%s() LN%d, failed to read json, childtable_count not found\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
g_Dbs.db[i].superTbls[j].childTblCount = count->valueint;
cJSON *dataSource = cJSON_GetObjectItem(stbInfo, "data_source");
if (dataSource && dataSource->type == cJSON_String
- && dataSource->valuestring != NULL) {
+ && dataSource->valuestring != NULL) {
tstrncpy(g_Dbs.db[i].superTbls[j].dataSource,
- dataSource->valuestring, MAX_DB_NAME_SIZE);
+ dataSource->valuestring, MAX_DB_NAME_SIZE);
} else if (!dataSource) {
tstrncpy(g_Dbs.db[i].superTbls[j].dataSource, "rand", MAX_DB_NAME_SIZE);
} else {
errorPrint("%s() LN%d, failed to read json, data_source not found\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
cJSON *insertMode = cJSON_GetObjectItem(stbInfo, "insert_mode"); // taosc , restful
if (insertMode && insertMode->type == cJSON_String
- && insertMode->valuestring != NULL) {
+ && insertMode->valuestring != NULL) {
tstrncpy(g_Dbs.db[i].superTbls[j].insertMode,
- insertMode->valuestring, MAX_DB_NAME_SIZE);
+ insertMode->valuestring, MAX_DB_NAME_SIZE);
} else if (!insertMode) {
tstrncpy(g_Dbs.db[i].superTbls[j].insertMode, "taosc", MAX_DB_NAME_SIZE);
} else {
@@ -3596,8 +3727,8 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
if ((childTbl_limit) && (g_Dbs.db[i].drop != true)
&& (g_Dbs.db[i].superTbls[j].childTblExists == TBL_ALREADY_EXISTS)) {
if (childTbl_limit->type != cJSON_Number) {
- printf("ERROR: failed to read json, childtable_limit\n");
- goto PARSE_OVER;
+ printf("ERROR: failed to read json, childtable_limit\n");
+ goto PARSE_OVER;
}
g_Dbs.db[i].superTbls[j].childTblLimit = childTbl_limit->valueint;
} else {
@@ -3608,8 +3739,8 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
if ((childTbl_offset) && (g_Dbs.db[i].drop != true)
&& (g_Dbs.db[i].superTbls[j].childTblExists == TBL_ALREADY_EXISTS)) {
if (childTbl_offset->type != cJSON_Number || 0 > childTbl_offset->valueint) {
- printf("ERROR: failed to read json, childtable_offset\n");
- goto PARSE_OVER;
+ printf("ERROR: failed to read json, childtable_offset\n");
+ goto PARSE_OVER;
}
g_Dbs.db[i].superTbls[j].childTblOffset = childTbl_offset->valueint;
} else {
@@ -3619,10 +3750,10 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
cJSON *ts = cJSON_GetObjectItem(stbInfo, "start_timestamp");
if (ts && ts->type == cJSON_String && ts->valuestring != NULL) {
tstrncpy(g_Dbs.db[i].superTbls[j].startTimestamp,
- ts->valuestring, MAX_DB_NAME_SIZE);
+ ts->valuestring, MAX_DB_NAME_SIZE);
} else if (!ts) {
tstrncpy(g_Dbs.db[i].superTbls[j].startTimestamp,
- "now", MAX_DB_NAME_SIZE);
+ "now", MAX_DB_NAME_SIZE);
} else {
printf("ERROR: failed to read json, start_timestamp not found\n");
goto PARSE_OVER;
@@ -3640,9 +3771,9 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
cJSON *sampleFormat = cJSON_GetObjectItem(stbInfo, "sample_format");
if (sampleFormat && sampleFormat->type
- == cJSON_String && sampleFormat->valuestring != NULL) {
+ == cJSON_String && sampleFormat->valuestring != NULL) {
tstrncpy(g_Dbs.db[i].superTbls[j].sampleFormat,
- sampleFormat->valuestring, MAX_DB_NAME_SIZE);
+ sampleFormat->valuestring, MAX_DB_NAME_SIZE);
} else if (!sampleFormat) {
tstrncpy(g_Dbs.db[i].superTbls[j].sampleFormat, "csv", MAX_DB_NAME_SIZE);
} else {
@@ -3654,7 +3785,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
if (sampleFile && sampleFile->type == cJSON_String
&& sampleFile->valuestring != NULL) {
tstrncpy(g_Dbs.db[i].superTbls[j].sampleFile,
- sampleFile->valuestring, MAX_FILE_NAME_LEN);
+ sampleFile->valuestring, MAX_FILE_NAME_LEN);
} else if (!sampleFile) {
memset(g_Dbs.db[i].superTbls[j].sampleFile, 0, MAX_FILE_NAME_LEN);
} else {
@@ -3665,7 +3796,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
cJSON *tagsFile = cJSON_GetObjectItem(stbInfo, "tags_file");
if (tagsFile && tagsFile->type == cJSON_String && tagsFile->valuestring != NULL) {
tstrncpy(g_Dbs.db[i].superTbls[j].tagsFile,
- tagsFile->valuestring, MAX_FILE_NAME_LEN);
+ tagsFile->valuestring, MAX_FILE_NAME_LEN);
if (0 == g_Dbs.db[i].superTbls[j].tagsFile[0]) {
g_Dbs.db[i].superTbls[j].tagSource = 0;
} else {
@@ -3692,7 +3823,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
g_Dbs.db[i].superTbls[j].maxSqlLen = g_args.max_sql_len;
} else {
errorPrint("%s() LN%d, failed to read json, maxSqlLen input mistake\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
/*
@@ -3719,9 +3850,9 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
// rows per table need be less than insert batch
if (g_Dbs.db[i].superTbls[j].interlaceRows > g_args.num_of_RPR) {
printf("NOTICE: db[%d].superTbl[%d]'s interlace rows value %d > num_of_records_per_req %d\n\n",
- i, j, g_Dbs.db[i].superTbls[j].interlaceRows, g_args.num_of_RPR);
+ i, j, g_Dbs.db[i].superTbls[j].interlaceRows, g_args.num_of_RPR);
printf(" interlace rows value will be set to num_of_records_per_req %d\n\n",
- g_args.num_of_RPR);
+ g_args.num_of_RPR);
printf(" press Enter key to continue or Ctrl-C to stop.");
(void)getchar();
g_Dbs.db[i].superTbls[j].interlaceRows = g_args.num_of_RPR;
@@ -3730,8 +3861,8 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
g_Dbs.db[i].superTbls[j].interlaceRows = 0; // 0 means progressive mode, > 0 mean interlace mode. max value is less or equ num_of_records_per_req
} else {
errorPrint(
- "%s() LN%d, failed to read json, interlace rows input mistake\n",
- __func__, __LINE__);
+ "%s() LN%d, failed to read json, interlace rows input mistake\n",
+ __func__, __LINE__);
goto PARSE_OVER;
}
@@ -3768,7 +3899,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
g_Dbs.db[i].superTbls[j].insertRows = 0x7FFFFFFFFFFFFFFF;
} else {
errorPrint("%s() LN%d, failed to read json, insert_rows input mistake\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
@@ -3777,16 +3908,16 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
g_Dbs.db[i].superTbls[j].insertInterval = insertInterval->valueint;
} else if (!insertInterval) {
verbosePrint("%s() LN%d: stable insert interval be overrided by global %d.\n",
- __func__, __LINE__, g_args.insert_interval);
+ __func__, __LINE__, g_args.insert_interval);
g_Dbs.db[i].superTbls[j].insertInterval = g_args.insert_interval;
} else {
errorPrint("%s() LN%d, failed to read json, insert_interval input mistake\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
int retVal = getColumnAndTagTypeFromInsertJsonFile(
- stbInfo, &g_Dbs.db[i].superTbls[j]);
+ stbInfo, &g_Dbs.db[i].superTbls[j]);
if (false == retVal) {
goto PARSE_OVER;
}
@@ -3795,7 +3926,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
ret = true;
-PARSE_OVER:
+ PARSE_OVER:
return ret;
}
@@ -3840,7 +3971,7 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
cJSON *answerPrompt = cJSON_GetObjectItem(root, "confirm_parameter_prompt"); // yes, no,
if (answerPrompt && answerPrompt->type == cJSON_String
- && answerPrompt->valuestring != NULL) {
+ && answerPrompt->valuestring != NULL) {
if (0 == strncasecmp(answerPrompt->valuestring, "yes", 3)) {
g_args.answer_yes = false;
} else if (0 == strncasecmp(answerPrompt->valuestring, "no", 2)) {
@@ -3862,7 +3993,7 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
g_args.query_times = 1;
} else {
errorPrint("%s() LN%d, failed to read json, query_times input mistake\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
@@ -3893,22 +4024,22 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
printf("ERROR: failed to read json, super_table_query not found\n");
goto PARSE_OVER;
} else {
- cJSON* rate = cJSON_GetObjectItem(specifiedQuery, "query_interval");
- if (rate && rate->type == cJSON_Number) {
- g_queryInfo.specifiedQueryInfo.rate = rate->valueint;
- } else if (!rate) {
- g_queryInfo.specifiedQueryInfo.rate = 0;
+ cJSON* queryInterval = cJSON_GetObjectItem(specifiedQuery, "query_interval");
+ if (queryInterval && queryInterval->type == cJSON_Number) {
+ g_queryInfo.specifiedQueryInfo.queryInterval = queryInterval->valueint;
+ } else if (!queryInterval) {
+ g_queryInfo.specifiedQueryInfo.queryInterval = 0;
}
cJSON* specifiedQueryTimes = cJSON_GetObjectItem(specifiedQuery,
- "query_times");
+ "query_times");
if (specifiedQueryTimes && specifiedQueryTimes->type == cJSON_Number) {
g_queryInfo.specifiedQueryInfo.queryTimes = specifiedQueryTimes->valueint;
} else if (!specifiedQueryTimes) {
g_queryInfo.specifiedQueryInfo.queryTimes = g_args.query_times;
} else {
errorPrint("%s() LN%d, failed to read json, query_times input mistake\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
@@ -3917,24 +4048,24 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
g_queryInfo.specifiedQueryInfo.concurrent = concurrent->valueint;
if (g_queryInfo.specifiedQueryInfo.concurrent <= 0) {
errorPrint("%s() LN%d, query sqlCount %d or concurrent %d is not correct.\n",
- __func__, __LINE__, g_queryInfo.specifiedQueryInfo.sqlCount,
- g_queryInfo.specifiedQueryInfo.concurrent);
+ __func__, __LINE__, g_queryInfo.specifiedQueryInfo.sqlCount,
+ g_queryInfo.specifiedQueryInfo.concurrent);
goto PARSE_OVER;
}
} else if (!concurrent) {
g_queryInfo.specifiedQueryInfo.concurrent = 1;
}
- cJSON* queryMode = cJSON_GetObjectItem(specifiedQuery, "mode");
- if (queryMode && queryMode->type == cJSON_String
- && queryMode->valuestring != NULL) {
- if (0 == strcmp("sync", queryMode->valuestring)) {
+ cJSON* mode = cJSON_GetObjectItem(specifiedQuery, "mode");
+ if (mode && mode->type == cJSON_String
+ && mode->valuestring != NULL) {
+ if (0 == strcmp("sync", mode->valuestring)) {
g_queryInfo.specifiedQueryInfo.mode = SYNC_QUERY_MODE;
- } else if (0 == strcmp("async", queryMode->valuestring)) {
+ } else if (0 == strcmp("async", mode->valuestring)) {
g_queryInfo.specifiedQueryInfo.mode = ASYNC_QUERY_MODE;
} else {
errorPrint("%s() LN%d, failed to read json, query mode input error\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
} else {
@@ -3966,8 +4097,8 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
cJSON* keepProgress = cJSON_GetObjectItem(specifiedQuery, "keepProgress");
if (keepProgress
- && keepProgress->type == cJSON_String
- && keepProgress->valuestring != NULL) {
+ && keepProgress->type == cJSON_String
+ && keepProgress->valuestring != NULL) {
if (0 == strcmp("yes", keepProgress->valuestring)) {
g_queryInfo.specifiedQueryInfo.subscribeKeepProgress = 1;
} else if (0 == strcmp("no", keepProgress->valuestring)) {
@@ -3986,13 +4117,13 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
g_queryInfo.specifiedQueryInfo.sqlCount = 0;
} else if (superSqls->type != cJSON_Array) {
errorPrint("%s() LN%d, failed to read json, super sqls not found\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
} else {
int superSqlSize = cJSON_GetArraySize(superSqls);
if (superSqlSize > MAX_QUERY_SQL_COUNT) {
errorPrint("%s() LN%d, failed to read json, query sql size overflow, max is %d\n",
- __func__, __LINE__, MAX_QUERY_SQL_COUNT);
+ __func__, __LINE__, MAX_QUERY_SQL_COUNT);
goto PARSE_OVER;
}
@@ -4033,9 +4164,9 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
} else {
cJSON* subrate = cJSON_GetObjectItem(superQuery, "query_interval");
if (subrate && subrate->type == cJSON_Number) {
- g_queryInfo.superQueryInfo.rate = subrate->valueint;
+ g_queryInfo.superQueryInfo.queryInterval = subrate->valueint;
} else if (!subrate) {
- g_queryInfo.superQueryInfo.rate = 0;
+ g_queryInfo.superQueryInfo.queryInterval = 0;
}
cJSON* superQueryTimes = cJSON_GetObjectItem(superQuery, "query_times");
@@ -4045,7 +4176,7 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
g_queryInfo.superQueryInfo.queryTimes = g_args.query_times;
} else {
errorPrint("%s() LN%d, failed to read json, query_times input mistake\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
@@ -4067,10 +4198,10 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
if (stblname && stblname->type == cJSON_String
&& stblname->valuestring != NULL) {
tstrncpy(g_queryInfo.superQueryInfo.sTblName, stblname->valuestring,
- MAX_TB_NAME_SIZE);
+ MAX_TB_NAME_SIZE);
} else {
errorPrint("%s() LN%d, failed to read json, super table name input error\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
@@ -4083,7 +4214,7 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
g_queryInfo.superQueryInfo.mode = ASYNC_QUERY_MODE;
} else {
errorPrint("%s() LN%d, failed to read json, query mode input error\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
} else {
@@ -4116,8 +4247,8 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
cJSON* subkeepProgress = cJSON_GetObjectItem(superQuery, "keepProgress");
if (subkeepProgress &&
- subkeepProgress->type == cJSON_String
- && subkeepProgress->valuestring != NULL) {
+ subkeepProgress->type == cJSON_String
+ && subkeepProgress->valuestring != NULL) {
if (0 == strcmp("yes", subkeepProgress->valuestring)) {
g_queryInfo.superQueryInfo.subscribeKeepProgress = 1;
} else if (0 == strcmp("no", subkeepProgress->valuestring)) {
@@ -4136,13 +4267,13 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
g_queryInfo.superQueryInfo.sqlCount = 0;
} else if (subsqls->type != cJSON_Array) {
errorPrint("%s() LN%d: failed to read json, super sqls not found\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
} else {
int superSqlSize = cJSON_GetArraySize(subsqls);
if (superSqlSize > MAX_QUERY_SQL_COUNT) {
errorPrint("%s() LN%d, failed to read json, query sql size overflow, max is %d\n",
- __func__, __LINE__, MAX_QUERY_SQL_COUNT);
+ __func__, __LINE__, MAX_QUERY_SQL_COUNT);
goto PARSE_OVER;
}
@@ -4155,22 +4286,22 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
if (!sqlStr || sqlStr->type != cJSON_String
|| sqlStr->valuestring == NULL) {
errorPrint("%s() LN%d, failed to read json, sql not found\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
tstrncpy(g_queryInfo.superQueryInfo.sql[j], sqlStr->valuestring,
- MAX_QUERY_SQL_LENGTH);
+ MAX_QUERY_SQL_LENGTH);
cJSON *result = cJSON_GetObjectItem(sql, "result");
if (result != NULL && result->type == cJSON_String
&& result->valuestring != NULL){
tstrncpy(g_queryInfo.superQueryInfo.result[j],
- result->valuestring, MAX_FILE_NAME_LEN);
+ result->valuestring, MAX_FILE_NAME_LEN);
} else if (NULL == result) {
memset(g_queryInfo.superQueryInfo.result[j], 0, MAX_FILE_NAME_LEN);
} else {
errorPrint("%s() LN%d, failed to read json, sub query result file not found\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
}
@@ -4179,12 +4310,12 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
ret = true;
-PARSE_OVER:
+ PARSE_OVER:
return ret;
}
static bool getInfoFromJsonFile(char* file) {
- debugPrint("%s %d %s\n", __func__, __LINE__, file);
+ debugPrint("%s %d %s\n", __func__, __LINE__, file);
FILE *fp = fopen(file, "r");
if (!fp) {
@@ -4232,15 +4363,15 @@ static bool getInfoFromJsonFile(char* file) {
if (INSERT_TEST == g_args.test_mode) {
ret = getMetaFromInsertJsonFile(root);
} else if ((QUERY_TEST == g_args.test_mode)
- || (SUBSCRIBE_TEST == g_args.test_mode)) {
+ || (SUBSCRIBE_TEST == g_args.test_mode)) {
ret = getMetaFromQueryJsonFile(root);
} else {
errorPrint("%s() LN%d, input json file type error! please input correct file type: insert or query or subscribe\n",
- __func__, __LINE__);
+ __func__, __LINE__);
goto PARSE_OVER;
}
-PARSE_OVER:
+ PARSE_OVER:
free(content);
cJSON_Delete(root);
fclose(fp);
@@ -4282,7 +4413,7 @@ static void postFreeResource() {
}
static int getRowDataFromSample(char* dataBuf, int maxLen, int64_t timestamp,
- SSuperTable* superTblInfo, int* sampleUsePos) {
+ SSuperTable* superTblInfo, int* sampleUsePos) {
if ((*sampleUsePos) == MAX_SAMPLES_ONCE_FROM_FILE) {
/* int ret = readSampleFromCsvFileToMem(superTblInfo);
if (0 != ret) {
@@ -4297,9 +4428,9 @@ static int getRowDataFromSample(char* dataBuf, int maxLen, int64_t timestamp,
int dataLen = 0;
dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen,
- "(%" PRId64 ", ", timestamp);
+ "(%" PRId64 ", ", timestamp);
dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen,
- "%s", superTblInfo->sampleDataBuf + superTblInfo->lenOfOneRow * (*sampleUsePos));
+ "%s", superTblInfo->sampleDataBuf + superTblInfo->lenOfOneRow * (*sampleUsePos));
dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, ")");
(*sampleUsePos)++;
@@ -4316,10 +4447,10 @@ static int generateRowData(char* recBuf, int64_t timestamp, SSuperTable* stbInfo
for (int i = 0; i < stbInfo->columnCount; i++) {
if ((0 == strncasecmp(stbInfo->columns[i].dataType, "binary", 6))
- || (0 == strncasecmp(stbInfo->columns[i].dataType, "nchar", 5))) {
+ || (0 == strncasecmp(stbInfo->columns[i].dataType, "nchar", 5))) {
if (stbInfo->columns[i].dataLen > TSDB_MAX_BINARY_LEN) {
errorPrint( "binary or nchar length overflow, max size:%u\n",
- (uint32_t)TSDB_MAX_BINARY_LEN);
+ (uint32_t)TSDB_MAX_BINARY_LEN);
return -1;
}
@@ -4332,37 +4463,37 @@ static int generateRowData(char* recBuf, int64_t timestamp, SSuperTable* stbInfo
dataLen += snprintf(pstr + dataLen, maxLen - dataLen, "\'%s\', ", buf);
tmfree(buf);
} else if (0 == strncasecmp(stbInfo->columns[i].dataType,
- "int", 3)) {
+ "int", 3)) {
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
- "%d, ", rand_int());
+ "%d, ", rand_int());
} else if (0 == strncasecmp(stbInfo->columns[i].dataType,
- "bigint", 6)) {
+ "bigint", 6)) {
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
- "%"PRId64", ", rand_bigint());
+ "%"PRId64", ", rand_bigint());
} else if (0 == strncasecmp(stbInfo->columns[i].dataType,
- "float", 5)) {
+ "float", 5)) {
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
- "%f, ", rand_float());
+ "%f, ", rand_float());
} else if (0 == strncasecmp(stbInfo->columns[i].dataType,
- "double", 6)) {
+ "double", 6)) {
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
- "%f, ", rand_double());
+ "%f, ", rand_double());
} else if (0 == strncasecmp(stbInfo->columns[i].dataType,
- "smallint", 8)) {
+ "smallint", 8)) {
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
- "%d, ", rand_smallint());
+ "%d, ", rand_smallint());
} else if (0 == strncasecmp(stbInfo->columns[i].dataType,
- "tinyint", strlen("tinyint"))) {
+ "tinyint", strlen("tinyint"))) {
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
- "%d, ", rand_tinyint());
+ "%d, ", rand_tinyint());
} else if (0 == strncasecmp(stbInfo->columns[i].dataType,
- "bool", strlen("bool"))) {
+ "bool", strlen("bool"))) {
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
- "%d, ", rand_bool());
+ "%d, ", rand_bool());
} else if (0 == strncasecmp(stbInfo->columns[i].dataType,
- "timestamp", strlen("timestamp"))) {
+ "timestamp", strlen("timestamp"))) {
dataLen += snprintf(pstr + dataLen, maxLen - dataLen,
- "%"PRId64", ", rand_bigint());
+ "%"PRId64", ", rand_bigint());
} else {
errorPrint( "No support data type: %s\n", stbInfo->columns[i].dataType);
return -1;
@@ -4378,7 +4509,7 @@ static int generateRowData(char* recBuf, int64_t timestamp, SSuperTable* stbInfo
}
static int32_t generateData(char *recBuf, char **data_type,
- int num_of_cols, int64_t timestamp, int lenOfBinary) {
+ int num_of_cols, int64_t timestamp, int lenOfBinary) {
memset(recBuf, 0, MAX_DATA_SIZE);
char *pstr = recBuf;
pstr += sprintf(pstr, "(%" PRId64, timestamp);
@@ -4395,7 +4526,7 @@ static int32_t generateData(char *recBuf, char **data_type,
exit(-1);
}
- for (int i = 0; i < num_of_cols; i++) {
+ for (int i = 0; i < c; i++) {
if (strcasecmp(data_type[i % c], "tinyint") == 0) {
pstr += sprintf(pstr, ", %d", rand_tinyint() );
} else if (strcasecmp(data_type[i % c], "smallint") == 0) {
@@ -4417,7 +4548,7 @@ static int32_t generateData(char *recBuf, char **data_type,
rand_string(s, lenOfBinary);
pstr += sprintf(pstr, ", \"%s\"", s);
free(s);
- }else if (strcasecmp(data_type[i % c], "nchar") == 0) {
+ } else if (strcasecmp(data_type[i % c], "nchar") == 0) {
char *s = malloc(lenOfBinary);
rand_string(s, lenOfBinary);
pstr += sprintf(pstr, ", \"%s\"", s);
@@ -4441,24 +4572,24 @@ static int prepareSampleDataForSTable(SSuperTable *superTblInfo) {
char* sampleDataBuf = NULL;
sampleDataBuf = calloc(
- superTblInfo->lenOfOneRow * MAX_SAMPLES_ONCE_FROM_FILE, 1);
+ superTblInfo->lenOfOneRow * MAX_SAMPLES_ONCE_FROM_FILE, 1);
if (sampleDataBuf == NULL) {
- errorPrint("%s() LN%d, Failed to calloc %d Bytes, reason:%s\n",
- __func__, __LINE__,
- superTblInfo->lenOfOneRow * MAX_SAMPLES_ONCE_FROM_FILE,
- strerror(errno));
- return -1;
+ errorPrint("%s() LN%d, Failed to calloc %d Bytes, reason:%s\n",
+ __func__, __LINE__,
+ superTblInfo->lenOfOneRow * MAX_SAMPLES_ONCE_FROM_FILE,
+ strerror(errno));
+ return -1;
}
superTblInfo->sampleDataBuf = sampleDataBuf;
int ret = readSampleFromCsvFileToMem(superTblInfo);
if (0 != ret) {
- errorPrint("%s() LN%d, read sample from csv file failed.\n",
- __func__, __LINE__);
- tmfree(sampleDataBuf);
- superTblInfo->sampleDataBuf = NULL;
- return -1;
+ errorPrint("%s() LN%d, read sample from csv file failed.\n",
+ __func__, __LINE__);
+ tmfree(sampleDataBuf);
+ superTblInfo->sampleDataBuf = NULL;
+ return -1;
}
return 0;
@@ -4470,7 +4601,7 @@ static int execInsert(threadInfo *pThreadInfo, char *buffer, int k)
SSuperTable* superTblInfo = pThreadInfo->superTblInfo;
verbosePrint("[%d] %s() LN%d %s\n", pThreadInfo->threadID,
- __func__, __LINE__, buffer);
+ __func__, __LINE__, buffer);
if (superTblInfo) {
if (0 == strncasecmp(superTblInfo->insertMode, "taosc", strlen("taosc"))) {
affectedRows = queryDbExec(pThreadInfo->taos, buffer, INSERT_TYPE, false);
@@ -4478,7 +4609,7 @@ static int execInsert(threadInfo *pThreadInfo, char *buffer, int k)
if (0 != postProceSql(g_Dbs.host, g_Dbs.port, buffer)) {
affectedRows = -1;
printf("========restful return fail, threadID[%d]\n",
- pThreadInfo->threadID);
+ pThreadInfo->threadID);
} else {
affectedRows = k;
}
@@ -4495,29 +4626,29 @@ static void getTableName(char *pTblName, threadInfo* pThreadInfo, int tableSeq)
SSuperTable* superTblInfo = pThreadInfo->superTblInfo;
if (superTblInfo) {
if ((superTblInfo->childTblOffset >= 0)
- && (superTblInfo->childTblLimit > 0)) {
- snprintf(pTblName, TSDB_TABLE_NAME_LEN, "%s",
- superTblInfo->childTblName +
- (tableSeq - superTblInfo->childTblOffset) * TSDB_TABLE_NAME_LEN);
+ && (superTblInfo->childTblLimit > 0)) {
+ snprintf(pTblName, TSDB_TABLE_NAME_LEN, "%s",
+ superTblInfo->childTblName +
+ (tableSeq - superTblInfo->childTblOffset) * TSDB_TABLE_NAME_LEN);
} else {
- verbosePrint("[%d] %s() LN%d: from=%d count=%d seq=%d\n",
- pThreadInfo->threadID, __func__, __LINE__,
- pThreadInfo->start_table_from,
- pThreadInfo->ntables, tableSeq);
- snprintf(pTblName, TSDB_TABLE_NAME_LEN, "%s",
- superTblInfo->childTblName + tableSeq * TSDB_TABLE_NAME_LEN);
+ verbosePrint("[%d] %s() LN%d: from=%d count=%d seq=%d\n",
+ pThreadInfo->threadID, __func__, __LINE__,
+ pThreadInfo->start_table_from,
+ pThreadInfo->ntables, tableSeq);
+ snprintf(pTblName, TSDB_TABLE_NAME_LEN, "%s",
+ superTblInfo->childTblName + tableSeq * TSDB_TABLE_NAME_LEN);
}
} else {
snprintf(pTblName, TSDB_TABLE_NAME_LEN, "%s%d",
- g_args.tb_prefix, tableSeq);
+ g_args.tb_prefix, tableSeq);
}
}
static int generateDataTail(
- SSuperTable* superTblInfo,
- int batch, char* buffer, int remainderBufLen, int64_t insertRows,
- int64_t startFrom, uint64_t startTime, int *pSamplePos, int *dataLen) {
+ SSuperTable* superTblInfo,
+ int batch, char* buffer, int remainderBufLen, int64_t insertRows,
+ int64_t startFrom, uint64_t startTime, int *pSamplePos, int *dataLen) {
int len = 0;
int ncols_per_record = 1; // count first col ts
@@ -4526,8 +4657,8 @@ static int generateDataTail(
if (superTblInfo == NULL) {
int datatypeSeq = 0;
while(g_args.datatype[datatypeSeq]) {
- datatypeSeq ++;
- ncols_per_record ++;
+ datatypeSeq ++;
+ ncols_per_record ++;
}
}
@@ -4542,15 +4673,15 @@ static int generateDataTail(
if (superTblInfo) {
if (0 == strncasecmp(superTblInfo->dataSource,
- "sample", strlen("sample"))) {
- retLen = getRowDataFromSample(
- data,
- remainderBufLen,
- startTime + superTblInfo->timeStampStep * k,
- superTblInfo,
- pSamplePos);
+ "sample", strlen("sample"))) {
+ retLen = getRowDataFromSample(
+ data,
+ remainderBufLen,
+ startTime + superTblInfo->timeStampStep * k,
+ superTblInfo,
+ pSamplePos);
} else if (0 == strncasecmp(superTblInfo->dataSource,
- "rand", strlen("rand"))) {
+ "rand", strlen("rand"))) {
int randTail = superTblInfo->timeStampStep * k;
if (superTblInfo->disorderRatio > 0) {
@@ -4562,11 +4693,11 @@ static int generateDataTail(
}
uint64_t d = startTime
- + randTail;
+ + randTail;
retLen = generateRowData(
- data,
- d,
- superTblInfo);
+ data,
+ d,
+ superTblInfo);
}
if (retLen > remainderBufLen) {
@@ -4585,30 +4716,30 @@ static int generateDataTail(
int randTail;
if ((g_args.disorderRatio != 0)
- && (rand_num < g_args.disorderRatio)) {
+ && (rand_num < g_args.disorderRatio)) {
randTail = (DEFAULT_TIMESTAMP_STEP * k
- + (taosRandom() % g_args.disorderRange + 1)) * (-1);
+ + (taosRandom() % g_args.disorderRange + 1)) * (-1);
debugPrint("rand data generated, back %d\n", randTail);
} else {
randTail = DEFAULT_TIMESTAMP_STEP * k;
}
retLen = generateData(data, data_type,
- ncols_per_record,
- startTime + randTail,
- lenOfBinary);
+ ncols_per_record,
+ startTime + randTail,
+ lenOfBinary);
if (len > remainderBufLen)
break;
- pstr += sprintf(pstr, " %s", data);
+ pstr += sprintf(pstr, "%s", data);
k++;
len += retLen;
remainderBufLen -= retLen;
}
verbosePrint("%s() LN%d len=%d k=%d \nbuffer=%s\n",
- __func__, __LINE__, len, k, buffer);
+ __func__, __LINE__, len, k, buffer);
startFrom ++;
@@ -4622,8 +4753,8 @@ static int generateDataTail(
}
static int generateSQLHead(char *tableName, int32_t tableSeq,
- threadInfo* pThreadInfo, SSuperTable* superTblInfo,
- char *buffer, int remainderBufLen)
+ threadInfo* pThreadInfo, SSuperTable* superTblInfo,
+ char *buffer, int remainderBufLen)
{
int len;
@@ -4634,50 +4765,50 @@ static int generateSQLHead(char *tableName, int32_t tableSeq,
if (AUTO_CREATE_SUBTBL == superTblInfo->autoCreateTable) {
char* tagsValBuf = NULL;
if (0 == superTblInfo->tagSource) {
- tagsValBuf = generateTagVaulesForStb(superTblInfo, tableSeq);
+ tagsValBuf = generateTagVaulesForStb(superTblInfo, tableSeq);
} else {
- tagsValBuf = getTagValueFromTagSample(
- superTblInfo,
- tableSeq % superTblInfo->tagSampleCount);
+ tagsValBuf = getTagValueFromTagSample(
+ superTblInfo,
+ tableSeq % superTblInfo->tagSampleCount);
}
if (NULL == tagsValBuf) {
errorPrint("%s() LN%d, tag buf failed to allocate memory\n",
- __func__, __LINE__);
+ __func__, __LINE__);
return -1;
}
len = snprintf(
headBuf,
- HEAD_BUFF_LEN,
- "%s.%s using %s.%s tags %s values",
- pThreadInfo->db_name,
- tableName,
- pThreadInfo->db_name,
- superTblInfo->sTblName,
- tagsValBuf);
+ HEAD_BUFF_LEN,
+ "%s.%s using %s.%s tags %s values",
+ pThreadInfo->db_name,
+ tableName,
+ pThreadInfo->db_name,
+ superTblInfo->sTblName,
+ tagsValBuf);
tmfree(tagsValBuf);
} else if (TBL_ALREADY_EXISTS == superTblInfo->childTblExists) {
len = snprintf(
headBuf,
- HEAD_BUFF_LEN,
- "%s.%s values",
- pThreadInfo->db_name,
- tableName);
+ HEAD_BUFF_LEN,
+ "%s.%s values",
+ pThreadInfo->db_name,
+ tableName);
} else {
len = snprintf(
headBuf,
- HEAD_BUFF_LEN,
- "%s.%s values",
- pThreadInfo->db_name,
- tableName);
+ HEAD_BUFF_LEN,
+ "%s.%s values",
+ pThreadInfo->db_name,
+ tableName);
}
} else {
- len = snprintf(
- headBuf,
- HEAD_BUFF_LEN,
- "%s.%s values",
- pThreadInfo->db_name,
- tableName);
+ len = snprintf(
+ headBuf,
+ HEAD_BUFF_LEN,
+ "%s.%s values",
+ pThreadInfo->db_name,
+ tableName);
}
if (len > remainderBufLen)
@@ -4689,26 +4820,26 @@ static int generateSQLHead(char *tableName, int32_t tableSeq,
}
static int generateInterlaceDataBuffer(
- char *tableName, int batchPerTbl, int i, int batchPerTblTimes,
- int32_t tableSeq,
- threadInfo *pThreadInfo, char *buffer,
- int64_t insertRows,
- int64_t startTime,
- int *pRemainderBufLen)
+ char *tableName, int batchPerTbl, int i, int batchPerTblTimes,
+ int32_t tableSeq,
+ threadInfo *pThreadInfo, char *buffer,
+ int64_t insertRows,
+ int64_t startTime,
+ int *pRemainderBufLen)
{
assert(buffer);
char *pstr = buffer;
SSuperTable* superTblInfo = pThreadInfo->superTblInfo;
int headLen = generateSQLHead(tableName, tableSeq, pThreadInfo,
- superTblInfo, pstr, *pRemainderBufLen);
+ superTblInfo, pstr, *pRemainderBufLen);
if (headLen <= 0) {
return 0;
}
// generate data buffer
verbosePrint("[%d] %s() LN%d i=%d buffer:\n%s\n",
- pThreadInfo->threadID, __func__, __LINE__, i, buffer);
+ pThreadInfo->threadID, __func__, __LINE__, i, buffer);
pstr += headLen;
*pRemainderBufLen -= headLen;
@@ -4716,22 +4847,22 @@ static int generateInterlaceDataBuffer(
int dataLen = 0;
verbosePrint("[%d] %s() LN%d i=%d batchPerTblTimes=%d batchPerTbl = %d\n",
- pThreadInfo->threadID, __func__, __LINE__,
- i, batchPerTblTimes, batchPerTbl);
+ pThreadInfo->threadID, __func__, __LINE__,
+ i, batchPerTblTimes, batchPerTbl);
if (superTblInfo) {
if (0 == strncasecmp(superTblInfo->startTimestamp, "now", 3)) {
startTime = taosGetTimestamp(pThreadInfo->time_precision);
}
} else {
- startTime = 1500000000000;
+ startTime = 1500000000000;
}
int k = generateDataTail(
- superTblInfo,
- batchPerTbl, pstr, *pRemainderBufLen, insertRows, 0,
- startTime,
- &(pThreadInfo->samplePos), &dataLen);
+ superTblInfo,
+ batchPerTbl, pstr, *pRemainderBufLen, insertRows, 0,
+ startTime,
+ &(pThreadInfo->samplePos), &dataLen);
if (k == batchPerTbl) {
pstr += dataLen;
@@ -4746,12 +4877,12 @@ static int generateInterlaceDataBuffer(
}
static int generateProgressiveDataBuffer(
- char *tableName,
- int32_t tableSeq,
- threadInfo *pThreadInfo, char *buffer,
- int64_t insertRows,
- int64_t startFrom, int64_t startTime, int *pSamplePos,
- int *pRemainderBufLen)
+ char *tableName,
+ int32_t tableSeq,
+ threadInfo *pThreadInfo, char *buffer,
+ int64_t insertRows,
+ int64_t startFrom, int64_t startTime, int *pSamplePos,
+ int *pRemainderBufLen)
{
SSuperTable* superTblInfo = pThreadInfo->superTblInfo;
@@ -4760,8 +4891,8 @@ static int generateProgressiveDataBuffer(
if (superTblInfo == NULL) {
int datatypeSeq = 0;
while(g_args.datatype[datatypeSeq]) {
- datatypeSeq ++;
- ncols_per_record ++;
+ datatypeSeq ++;
+ ncols_per_record ++;
}
}
@@ -4773,7 +4904,7 @@ static int generateProgressiveDataBuffer(
memset(buffer, 0, *pRemainderBufLen);
int headLen = generateSQLHead(tableName, tableSeq, pThreadInfo, superTblInfo,
- buffer, *pRemainderBufLen);
+ buffer, *pRemainderBufLen);
if (headLen <= 0) {
return 0;
@@ -4783,16 +4914,16 @@ static int generateProgressiveDataBuffer(
int dataLen;
k = generateDataTail(superTblInfo,
- g_args.num_of_RPR, pstr, *pRemainderBufLen, insertRows, startFrom,
- startTime,
- pSamplePos, &dataLen);
+ g_args.num_of_RPR, pstr, *pRemainderBufLen, insertRows, startFrom,
+ startTime,
+ pSamplePos, &dataLen);
return k;
}
static void* syncWriteInterlace(threadInfo *pThreadInfo) {
debugPrint("[%d] %s() LN%d: ### interlace write\n",
- pThreadInfo->threadID, __func__, __LINE__);
+ pThreadInfo->threadID, __func__, __LINE__);
SSuperTable* superTblInfo = pThreadInfo->superTblInfo;
@@ -4800,7 +4931,7 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
int interlaceRows = superTblInfo?superTblInfo->interlaceRows:g_args.interlace_rows;
if (interlaceRows > insertRows)
- interlaceRows = insertRows;
+ interlaceRows = insertRows;
if (interlaceRows > g_args.num_of_RPR)
interlaceRows = g_args.num_of_RPR;
@@ -4820,7 +4951,7 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
char* buffer = calloc(maxSqlLen, 1);
if (NULL == buffer) {
errorPrint( "%s() LN%d, Failed to alloc %d Bytes, reason:%s\n",
- __func__, __LINE__, maxSqlLen, strerror(errno));
+ __func__, __LINE__, maxSqlLen, strerror(errno));
return NULL;
}
@@ -4837,14 +4968,14 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
uint64_t et = 0xffffffff;
int64_t lastPrintTime = taosGetTimestampMs();
- int64_t startTs = taosGetTimestampUs();
+ int64_t startTs = taosGetTimestampMs();
int64_t endTs;
int tableSeq = pThreadInfo->start_table_from;
debugPrint("[%d] %s() LN%d: start_table_from=%d ntables=%d insertRows=%"PRId64"\n",
- pThreadInfo->threadID, __func__, __LINE__, pThreadInfo->start_table_from,
- pThreadInfo->ntables, insertRows);
+ pThreadInfo->threadID, __func__, __LINE__, pThreadInfo->start_table_from,
+ pThreadInfo->ntables, insertRows);
int64_t startTime = pThreadInfo->start_time;
@@ -4869,8 +5000,8 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
while(pThreadInfo->totalInsertRows < pThreadInfo->ntables * insertRows) {
if ((flagSleep) && (insert_interval)) {
- st = taosGetTimestampUs();
- flagSleep = false;
+ st = taosGetTimestampMs();
+ flagSleep = false;
}
// generate data
memset(buffer, 0, maxSqlLen);
@@ -4888,23 +5019,23 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
getTableName(tableName, pThreadInfo, tableSeq);
if (0 == strlen(tableName)) {
errorPrint("[%d] %s() LN%d, getTableName return null\n",
- pThreadInfo->threadID, __func__, __LINE__);
+ pThreadInfo->threadID, __func__, __LINE__);
free(buffer);
return NULL;
}
int oldRemainderLen = remainderBufLen;
int generated = generateInterlaceDataBuffer(
- tableName, batchPerTbl, i, batchPerTblTimes,
- tableSeq,
- pThreadInfo, pstr,
- insertRows,
- startTime,
- &remainderBufLen);
+ tableName, batchPerTbl, i, batchPerTblTimes,
+ tableSeq,
+ pThreadInfo, pstr,
+ insertRows,
+ startTime,
+ &remainderBufLen);
if (generated < 0) {
debugPrint("[%d] %s() LN%d, generated data is %d\n",
- pThreadInfo->threadID, __func__, __LINE__, generated);
+ pThreadInfo->threadID, __func__, __LINE__, generated);
goto free_and_statistics_interlace;
} else if (generated == 0) {
break;
@@ -4916,25 +5047,25 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
// startTime += batchPerTbl * superTblInfo->timeStampStep;
pThreadInfo->totalInsertRows += batchPerTbl;
verbosePrint("[%d] %s() LN%d batchPerTbl=%d recOfBatch=%d\n",
- pThreadInfo->threadID, __func__, __LINE__,
- batchPerTbl, recOfBatch);
+ pThreadInfo->threadID, __func__, __LINE__,
+ batchPerTbl, recOfBatch);
if (insertMode == INTERLACE_INSERT_MODE) {
- if (tableSeq == pThreadInfo->start_table_from + pThreadInfo->ntables) {
- // turn to first table
- tableSeq = pThreadInfo->start_table_from;
- generatedRecPerTbl += batchPerTbl;
+ if (tableSeq == pThreadInfo->start_table_from + pThreadInfo->ntables) {
+ // turn to first table
+ tableSeq = pThreadInfo->start_table_from;
+ generatedRecPerTbl += batchPerTbl;
- startTime = pThreadInfo->start_time
- + generatedRecPerTbl * nTimeStampStep;
+ startTime = pThreadInfo->start_time
+ + generatedRecPerTbl * nTimeStampStep;
- flagSleep = true;
- if (generatedRecPerTbl >= insertRows)
- break;
+ flagSleep = true;
+ if (generatedRecPerTbl >= insertRows)
+ break;
- if (pThreadInfo->ntables * batchPerTbl < g_args.num_of_RPR)
- break;
- }
+ if (pThreadInfo->ntables * batchPerTbl < g_args.num_of_RPR)
+ break;
+ }
}
int remainRows = insertRows - generatedRecPerTbl;
@@ -4942,27 +5073,27 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
batchPerTbl = remainRows;
verbosePrint("[%d] %s() LN%d generatedRecPerTbl=%d insertRows=%"PRId64"\n",
- pThreadInfo->threadID, __func__, __LINE__,
- generatedRecPerTbl, insertRows);
+ pThreadInfo->threadID, __func__, __LINE__,
+ generatedRecPerTbl, insertRows);
if ((g_args.num_of_RPR - recOfBatch) < batchPerTbl)
break;
}
verbosePrint("[%d] %s() LN%d recOfBatch=%d totalInsertRows=%"PRId64"\n",
- pThreadInfo->threadID, __func__, __LINE__, recOfBatch,
- pThreadInfo->totalInsertRows);
+ pThreadInfo->threadID, __func__, __LINE__, recOfBatch,
+ pThreadInfo->totalInsertRows);
verbosePrint("[%d] %s() LN%d, buffer=%s\n",
- pThreadInfo->threadID, __func__, __LINE__, buffer);
+ pThreadInfo->threadID, __func__, __LINE__, buffer);
- startTs = taosGetTimestampUs();
+ startTs = taosGetTimestampMs();
int affectedRows = execInsert(pThreadInfo, buffer, recOfBatch);
- endTs = taosGetTimestampUs();
+ endTs = taosGetTimestampMs();
int64_t delay = endTs - startTs;
- performancePrint("%s() LN%d, insert execution time is %10.6fms\n",
- __func__, __LINE__, delay/1000.0);
+ performancePrint("%s() LN%d, insert execution time is %"PRId64"ms\n",
+ __func__, __LINE__, delay);
if (delay > pThreadInfo->maxDelay) pThreadInfo->maxDelay = delay;
if (delay < pThreadInfo->minDelay) pThreadInfo->minDelay = delay;
@@ -4970,12 +5101,12 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
pThreadInfo->totalDelay += delay;
verbosePrint("[%d] %s() LN%d affectedRows=%d\n", pThreadInfo->threadID,
- __func__, __LINE__, affectedRows);
+ __func__, __LINE__, affectedRows);
if ((affectedRows < 0) || (recOfBatch != affectedRows)) {
- errorPrint("[%d] %s() LN%d execInsert insert %d, affected rows: %d\n%s\n",
- pThreadInfo->threadID, __func__, __LINE__,
- recOfBatch, affectedRows, buffer);
- goto free_and_statistics_interlace;
+ errorPrint("[%d] %s() LN%d execInsert insert %d, affected rows: %d\n%s\n",
+ pThreadInfo->threadID, __func__, __LINE__,
+ recOfBatch, affectedRows, buffer);
+ goto free_and_statistics_interlace;
}
pThreadInfo->totalAffectedRows += affectedRows;
@@ -4983,32 +5114,32 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
int64_t currentPrintTime = taosGetTimestampMs();
if (currentPrintTime - lastPrintTime > 30*1000) {
printf("thread[%d] has currently inserted rows: %"PRId64 ", affected rows: %"PRId64 "\n",
- pThreadInfo->threadID,
- pThreadInfo->totalInsertRows,
- pThreadInfo->totalAffectedRows);
+ pThreadInfo->threadID,
+ pThreadInfo->totalInsertRows,
+ pThreadInfo->totalAffectedRows);
lastPrintTime = currentPrintTime;
}
if ((insert_interval) && flagSleep) {
- et = taosGetTimestampUs();
+ et = taosGetTimestampMs();
- if (insert_interval > ((et - st)/1000) ) {
- int sleepTime = insert_interval - (et -st)/1000;
+ if (insert_interval > (et - st) ) {
+ int sleepTime = insert_interval - (et -st);
performancePrint("%s() LN%d sleep: %d ms for insert interval\n",
- __func__, __LINE__, sleepTime);
+ __func__, __LINE__, sleepTime);
taosMsleep(sleepTime); // ms
sleepTimeTotal += insert_interval;
}
}
}
-free_and_statistics_interlace:
+ free_and_statistics_interlace:
tmfree(buffer);
printf("====thread[%d] completed total inserted rows: %"PRId64 ", total affected rows: %"PRId64 "====\n",
- pThreadInfo->threadID,
- pThreadInfo->totalInsertRows,
- pThreadInfo->totalAffectedRows);
+ pThreadInfo->threadID,
+ pThreadInfo->totalInsertRows,
+ pThreadInfo->totalAffectedRows);
return NULL;
}
@@ -5029,13 +5160,13 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
char* buffer = calloc(maxSqlLen, 1);
if (NULL == buffer) {
errorPrint( "Failed to alloc %d Bytes, reason:%s\n",
- maxSqlLen,
- strerror(errno));
+ maxSqlLen,
+ strerror(errno));
return NULL;
}
int64_t lastPrintTime = taosGetTimestampMs();
- int64_t startTs = taosGetTimestampUs();
+ int64_t startTs = taosGetTimestampMs();
int64_t endTs;
int timeStampStep =
@@ -5052,25 +5183,25 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
pThreadInfo->samplePos = 0;
for (uint32_t tableSeq =
- pThreadInfo->start_table_from; tableSeq <= pThreadInfo->end_table_to;
- tableSeq ++) {
+ pThreadInfo->start_table_from; tableSeq <= pThreadInfo->end_table_to;
+ tableSeq ++) {
int64_t start_time = pThreadInfo->start_time;
int64_t insertRows = (superTblInfo)?superTblInfo->insertRows:g_args.num_of_DPT;
verbosePrint("%s() LN%d insertRows=%"PRId64"\n", __func__, __LINE__, insertRows);
for (int64_t i = 0; i < insertRows;) {
- /*
- if (insert_interval) {
- st = taosGetTimestampUs();
- }
- */
+ /*
+ if (insert_interval) {
+ st = taosGetTimestampMs();
+ }
+ */
char tableName[TSDB_TABLE_NAME_LEN];
getTableName(tableName, pThreadInfo, tableSeq);
verbosePrint("%s() LN%d: tid=%d seq=%d tableName=%s\n",
- __func__, __LINE__,
- pThreadInfo->threadID, tableSeq, tableName);
+ __func__, __LINE__,
+ pThreadInfo->threadID, tableSeq, tableName);
int remainderBufLen = maxSqlLen;
char *pstr = buffer;
@@ -5082,10 +5213,10 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
remainderBufLen -= len;
int generated = generateProgressiveDataBuffer(
- tableName, tableSeq, pThreadInfo, pstr, insertRows,
- i, start_time,
- &(pThreadInfo->samplePos),
- &remainderBufLen);
+ tableName, tableSeq, pThreadInfo, pstr, insertRows,
+ i, start_time,
+ &(pThreadInfo->samplePos),
+ &remainderBufLen);
if (generated > 0)
i += generated;
else
@@ -5094,14 +5225,14 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
start_time += generated * timeStampStep;
pThreadInfo->totalInsertRows += generated;
- startTs = taosGetTimestampUs();
+ startTs = taosGetTimestampMs();
int affectedRows = execInsert(pThreadInfo, buffer, generated);
- endTs = taosGetTimestampUs();
+ endTs = taosGetTimestampMs();
int64_t delay = endTs - startTs;
- performancePrint("%s() LN%d, insert execution time is %10.6fms\n",
- __func__, __LINE__, delay/1000.0);
+ performancePrint("%s() LN%d, insert execution time is %"PRId64"ms\n",
+ __func__, __LINE__, delay);
if (delay > pThreadInfo->maxDelay) pThreadInfo->maxDelay = delay;
if (delay < pThreadInfo->minDelay) pThreadInfo->minDelay = delay;
@@ -5116,9 +5247,9 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
int64_t currentPrintTime = taosGetTimestampMs();
if (currentPrintTime - lastPrintTime > 30*1000) {
printf("thread[%d] has currently inserted rows: %"PRId64 ", affected rows: %"PRId64 "\n",
- pThreadInfo->threadID,
- pThreadInfo->totalInsertRows,
- pThreadInfo->totalAffectedRows);
+ pThreadInfo->threadID,
+ pThreadInfo->totalInsertRows,
+ pThreadInfo->totalAffectedRows);
lastPrintTime = currentPrintTime;
}
@@ -5126,10 +5257,10 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
break;
/*
if (insert_interval) {
- et = taosGetTimestampUs();
+ et = taosGetTimestampMs();
- if (insert_interval > ((et - st)/1000) ) {
- int sleep_time = insert_interval - (et -st)/1000;
+ if (insert_interval > ((et - st)) ) {
+ int sleep_time = insert_interval - (et -st);
performancePrint("%s() LN%d sleep: %d ms for insert interval\n",
__func__, __LINE__, sleep_time);
taosMsleep(sleep_time); // ms
@@ -5140,21 +5271,21 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
if (g_args.verbose_print) {
if ((tableSeq == pThreadInfo->ntables - 1) && superTblInfo &&
- (0 == strncasecmp(
- superTblInfo->dataSource, "sample", strlen("sample")))) {
- verbosePrint("%s() LN%d samplePos=%d\n",
- __func__, __LINE__, pThreadInfo->samplePos);
+ (0 == strncasecmp(
+ superTblInfo->dataSource, "sample", strlen("sample")))) {
+ verbosePrint("%s() LN%d samplePos=%d\n",
+ __func__, __LINE__, pThreadInfo->samplePos);
}
}
} // tableSeq
-free_and_statistics_2:
+ free_and_statistics_2:
tmfree(buffer);
printf("====thread[%d] completed total inserted rows: %"PRId64 ", total affected rows: %"PRId64 "====\n",
- pThreadInfo->threadID,
- pThreadInfo->totalInsertRows,
- pThreadInfo->totalAffectedRows);
+ pThreadInfo->threadID,
+ pThreadInfo->totalInsertRows,
+ pThreadInfo->totalAffectedRows);
return NULL;
}
@@ -5181,9 +5312,9 @@ static void callBack(void *param, TAOS_RES *res, int code) {
int insert_interval =
superTblInfo?superTblInfo->insertInterval:g_args.insert_interval;
if (insert_interval) {
- pThreadInfo->et = taosGetTimestampUs();
- if (((pThreadInfo->et - pThreadInfo->st)/1000) < insert_interval) {
- taosMsleep(insert_interval - (pThreadInfo->et - pThreadInfo->st)/1000); // ms
+ pThreadInfo->et = taosGetTimestampMs();
+ if ((pThreadInfo->et - pThreadInfo->st) < insert_interval) {
+ taosMsleep(insert_interval - (pThreadInfo->et - pThreadInfo->st)); // ms
}
}
@@ -5191,7 +5322,7 @@ static void callBack(void *param, TAOS_RES *res, int code) {
char data[MAX_DATA_SIZE];
char *pstr = buffer;
pstr += sprintf(pstr, "insert into %s.%s%d values", pThreadInfo->db_name, pThreadInfo->tb_prefix,
- pThreadInfo->start_table_from);
+ pThreadInfo->start_table_from);
// if (pThreadInfo->counter >= pThreadInfo->superTblInfo->insertRows) {
if (pThreadInfo->counter >= g_args.num_of_RPR) {
pThreadInfo->start_table_from++;
@@ -5207,7 +5338,7 @@ static void callBack(void *param, TAOS_RES *res, int code) {
for (int i = 0; i < g_args.num_of_RPR; i++) {
int rand_num = taosRandom() % 100;
if (0 != pThreadInfo->superTblInfo->disorderRatio
- && rand_num < pThreadInfo->superTblInfo->disorderRatio) {
+ && rand_num < pThreadInfo->superTblInfo->disorderRatio) {
int64_t d = pThreadInfo->lastTs - (taosRandom() % pThreadInfo->superTblInfo->disorderRange + 1);
generateRowData(data, d, pThreadInfo->superTblInfo);
} else {
@@ -5222,7 +5353,7 @@ static void callBack(void *param, TAOS_RES *res, int code) {
}
if (insert_interval) {
- pThreadInfo->st = taosGetTimestampUs();
+ pThreadInfo->st = taosGetTimestampMs();
}
taos_query_a(pThreadInfo->taos, buffer, callBack, pThreadInfo);
free(buffer);
@@ -5241,7 +5372,7 @@ static void *asyncWrite(void *sarg) {
int insert_interval =
superTblInfo?superTblInfo->insertInterval:g_args.insert_interval;
if (insert_interval) {
- pThreadInfo->st = taosGetTimestampUs();
+ pThreadInfo->st = taosGetTimestampMs();
}
taos_query_a(pThreadInfo->taos, "show databases", callBack, pThreadInfo);
@@ -5251,7 +5382,7 @@ static void *asyncWrite(void *sarg) {
}
static void startMultiThreadInsertData(int threads, char* db_name,
- char* precision,SSuperTable* superTblInfo) {
+ char* precision,SSuperTable* superTblInfo) {
pthread_t *pids = malloc(threads * sizeof(pthread_t));
assert(pids != NULL);
@@ -5286,48 +5417,48 @@ static void startMultiThreadInsertData(int threads, char* db_name,
int64_t start_time;
if (superTblInfo) {
if (0 == strncasecmp(superTblInfo->startTimestamp, "now", 3)) {
- start_time = taosGetTimestamp(timePrec);
+ start_time = taosGetTimestamp(timePrec);
} else {
if (TSDB_CODE_SUCCESS != taosParseTime(
- superTblInfo->startTimestamp,
- &start_time,
- strlen(superTblInfo->startTimestamp),
- timePrec, 0)) {
- ERROR_EXIT("failed to parse time!\n");
+ superTblInfo->startTimestamp,
+ &start_time,
+ strlen(superTblInfo->startTimestamp),
+ timePrec, 0)) {
+ ERROR_EXIT("failed to parse time!\n");
}
}
} else {
- start_time = 1500000000000;
+ start_time = 1500000000000;
}
- double start = getCurrentTimeUs();
+ int64_t start = taosGetTimestampMs();
// read sample data from file first
if ((superTblInfo) && (0 == strncasecmp(superTblInfo->dataSource,
- "sample", strlen("sample")))) {
+ "sample", strlen("sample")))) {
if (0 != prepareSampleDataForSTable(superTblInfo)) {
errorPrint("%s() LN%d, prepare sample data for stable failed!\n",
- __func__, __LINE__);
+ __func__, __LINE__);
exit(-1);
}
}
// read sample data from file first
if ((superTblInfo) && (0 == strncasecmp(superTblInfo->dataSource,
- "sample", strlen("sample")))) {
+ "sample", strlen("sample")))) {
if (0 != prepareSampleDataForSTable(superTblInfo)) {
errorPrint("%s() LN%d, prepare sample data for stable failed!\n",
- __func__, __LINE__);
+ __func__, __LINE__);
exit(-1);
}
}
TAOS* taos = taos_connect(
- g_Dbs.host, g_Dbs.user,
- g_Dbs.password, db_name, g_Dbs.port);
+ g_Dbs.host, g_Dbs.user,
+ g_Dbs.password, db_name, g_Dbs.port);
if (NULL == taos) {
errorPrint("%s() LN%d, connect to server fail , reason: %s\n",
- __func__, __LINE__, taos_errstr(NULL));
+ __func__, __LINE__, taos_errstr(NULL));
exit(-1);
}
@@ -5337,16 +5468,16 @@ static void startMultiThreadInsertData(int threads, char* db_name,
if (superTblInfo) {
int limit, offset;
- if ((superTblInfo->childTblExists == TBL_NO_EXISTS) &&
- ((superTblInfo->childTblOffset != 0) || (superTblInfo->childTblLimit >= 0))) {
- printf("WARNING: offset and limit will not be used since the child tables are not exists!\n");
+ if ((NULL != g_args.sqlFile) && (superTblInfo->childTblExists == TBL_NO_EXISTS) &&
+ ((superTblInfo->childTblOffset != 0) || (superTblInfo->childTblLimit >= 0))) {
+ printf("WARNING: offset and limit will not be used since the child tables not exists!\n");
}
if ((superTblInfo->childTblExists == TBL_ALREADY_EXISTS)
- && (superTblInfo->childTblOffset >= 0)) {
+ && (superTblInfo->childTblOffset >= 0)) {
if ((superTblInfo->childTblLimit < 0)
|| ((superTblInfo->childTblOffset + superTblInfo->childTblLimit)
- > (superTblInfo->childTblCount))) {
+ > (superTblInfo->childTblCount))) {
superTblInfo->childTblLimit =
superTblInfo->childTblCount - superTblInfo->childTblOffset;
}
@@ -5372,7 +5503,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
}
if ((superTblInfo->childTblExists != TBL_NO_EXISTS)
- && (0 == superTblInfo->childTblLimit)) {
+ && (0 == superTblInfo->childTblLimit)) {
printf("WARNING: specified limit = 0, which cannot find table name to insert or query! \n");
if (!g_args.answer_yes) {
printf(" Press enter key to continue or Ctrl-C to stop\n\n");
@@ -5381,7 +5512,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
}
superTblInfo->childTblName = (char*)calloc(1,
- limit * TSDB_TABLE_NAME_LEN);
+ limit * TSDB_TABLE_NAME_LEN);
if (superTblInfo->childTblName == NULL) {
errorPrint("%s() LN%d, alloc memory failed!\n", __func__, __LINE__);
taos_close(taos);
@@ -5424,15 +5555,15 @@ static void startMultiThreadInsertData(int threads, char* db_name,
t_info->minDelay = INT16_MAX;
if ((NULL == superTblInfo) ||
- (0 == strncasecmp(superTblInfo->insertMode, "taosc", 5))) {
+ (0 == strncasecmp(superTblInfo->insertMode, "taosc", 5))) {
//t_info->taos = taos;
t_info->taos = taos_connect(
- g_Dbs.host, g_Dbs.user,
- g_Dbs.password, db_name, g_Dbs.port);
+ g_Dbs.host, g_Dbs.user,
+ g_Dbs.password, db_name, g_Dbs.port);
if (NULL == t_info->taos) {
errorPrint(
- "connect to server fail from insert sub thread, reason: %s\n",
- taos_errstr(NULL));
+ "connect to server fail from insert sub thread, reason: %s\n",
+ taos_errstr(NULL));
exit(-1);
}
} else {
@@ -5440,7 +5571,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
}
if ((NULL == superTblInfo)
- || (0 == superTblInfo->multiThreadWriteOneTbl)) {
+ || (0 == superTblInfo->multiThreadWriteOneTbl)) {
t_info->start_table_from = startFrom;
t_info->ntables = iend_table_to = i < b ? startFrom + a : startFrom + a - 1;
@@ -5476,15 +5607,15 @@ static void startMultiThreadInsertData(int threads, char* db_name,
taos_close(t_info->taos);
debugPrint("%s() LN%d, [%d] totalInsert=%"PRId64" totalAffected=%"PRId64"\n",
- __func__, __LINE__,
- t_info->threadID, t_info->totalInsertRows,
- t_info->totalAffectedRows);
+ __func__, __LINE__,
+ t_info->threadID, t_info->totalInsertRows,
+ t_info->totalAffectedRows);
if (superTblInfo) {
- superTblInfo->totalAffectedRows += t_info->totalAffectedRows;
- superTblInfo->totalInsertRows += t_info->totalInsertRows;
+ superTblInfo->totalAffectedRows += t_info->totalAffectedRows;
+ superTblInfo->totalInsertRows += t_info->totalInsertRows;
} else {
- g_args.totalAffectedRows += t_info->totalAffectedRows;
- g_args.totalInsertRows += t_info->totalInsertRows;
+ g_args.totalAffectedRows += t_info->totalAffectedRows;
+ g_args.totalInsertRows += t_info->totalInsertRows;
}
totalDelay += t_info->totalDelay;
@@ -5497,39 +5628,39 @@ static void startMultiThreadInsertData(int threads, char* db_name,
if (cntDelay == 0) cntDelay = 1;
avgDelay = (double)totalDelay / cntDelay;
- double end = getCurrentTimeUs();
- double t = end - start;
+ int64_t end = taosGetTimestampMs();
+ int64_t t = end - start;
if (superTblInfo) {
- printf("Spent %.4f seconds to insert rows: %"PRId64", affected rows: %"PRId64" with %d thread(s) into %s.%s. %2.f records/second\n\n",
- t, superTblInfo->totalInsertRows,
- superTblInfo->totalAffectedRows,
- threads, db_name, superTblInfo->sTblName,
- superTblInfo->totalInsertRows / t);
+ printf("Spent %.2f seconds to insert rows: %"PRId64", affected rows: %"PRId64" with %d thread(s) into %s.%s. %2.f records/second\n\n",
+ t / 1000.0, superTblInfo->totalInsertRows,
+ superTblInfo->totalAffectedRows,
+ threads, db_name, superTblInfo->sTblName,
+ (double)superTblInfo->totalInsertRows / (t / 1000.0));
fprintf(g_fpOfInsertResult,
- "Spent %.4f seconds to insert rows: %"PRId64", affected rows: %"PRId64" with %d thread(s) into %s.%s. %2.f records/second\n\n",
- t, superTblInfo->totalInsertRows,
- superTblInfo->totalAffectedRows,
- threads, db_name, superTblInfo->sTblName,
- superTblInfo->totalInsertRows/ t);
+ "Spent %.2f seconds to insert rows: %"PRId64", affected rows: %"PRId64" with %d thread(s) into %s.%s. %2.f records/second\n\n",
+ t / 1000.0, superTblInfo->totalInsertRows,
+ superTblInfo->totalAffectedRows,
+ threads, db_name, superTblInfo->sTblName,
+ (double)superTblInfo->totalInsertRows / (t / 1000.0));
} else {
- printf("Spent %.4f seconds to insert rows: %"PRId64", affected rows: %"PRId64" with %d thread(s) into %s %2.f records/second\n\n",
- t, g_args.totalInsertRows,
- g_args.totalAffectedRows,
- threads, db_name,
- g_args.totalInsertRows / t);
+ printf("Spent %.2f seconds to insert rows: %"PRId64", affected rows: %"PRId64" with %d thread(s) into %s %2.f records/second\n\n",
+ t / 1000.0, g_args.totalInsertRows,
+ g_args.totalAffectedRows,
+ threads, db_name,
+ (double)g_args.totalInsertRows / (t / 1000.0));
fprintf(g_fpOfInsertResult,
- "Spent %.4f seconds to insert rows: %"PRId64", affected rows: %"PRId64" with %d thread(s) into %s %2.f records/second\n\n",
- t, g_args.totalInsertRows,
- g_args.totalAffectedRows,
- threads, db_name,
- g_args.totalInsertRows / t);
+ "Spent %.2f seconds to insert rows: %"PRId64", affected rows: %"PRId64" with %d thread(s) into %s %2.f records/second\n\n",
+ t * 1000.0, g_args.totalInsertRows,
+ g_args.totalAffectedRows,
+ threads, db_name,
+ (double)g_args.totalInsertRows / (t / 1000.0));
}
- printf("insert delay, avg: %10.6fms, max: %10.6fms, min: %10.6fms\n\n",
- avgDelay/1000.0, (double)maxDelay/1000.0, (double)minDelay/1000.0);
- fprintf(g_fpOfInsertResult, "insert delay, avg:%10.6fms, max: %10.6fms, min: %10.6fms\n\n",
- avgDelay/1000.0, (double)maxDelay/1000.0, (double)minDelay/1000.0);
+ printf("insert delay, avg: %10.2fms, max: %"PRId64"ms, min: %"PRId64"ms\n\n",
+ avgDelay, maxDelay, minDelay);
+ fprintf(g_fpOfInsertResult, "insert delay, avg:%10.2fms, max: %"PRId64"ms, min: %"PRId64"ms\n\n",
+ avgDelay, maxDelay, minDelay);
//taos_close(taos);
@@ -5550,12 +5681,12 @@ static void *readTable(void *sarg) {
return NULL;
}
- int num_of_DPT;
+ int num_of_DPT;
/* if (rinfo->superTblInfo) {
num_of_DPT = rinfo->superTblInfo->insertRows; // nrecords_per_table;
} else {
*/
- num_of_DPT = g_args.num_of_DPT;
+ num_of_DPT = g_args.num_of_DPT;
// }
int num_of_tables = rinfo->ntables; // rinfo->end_table_to - rinfo->start_table_from + 1;
@@ -5576,7 +5707,7 @@ static void *readTable(void *sarg) {
sprintf(command, "select %s from %s%d where ts>= %" PRId64,
aggreFunc[j], tb_prefix, i, sTime);
- double t = getCurrentTimeUs();
+ double t = taosGetTimestampMs();
TAOS_RES *pSql = taos_query(taos, command);
int32_t code = taos_errno(pSql);
@@ -5592,7 +5723,7 @@ static void *readTable(void *sarg) {
count++;
}
- t = getCurrentTimeUs() - t;
+ t = taosGetTimestampMs() - t;
totalT += t;
taos_free_result(pSql);
@@ -5601,7 +5732,7 @@ static void *readTable(void *sarg) {
fprintf(fp, "|%10s | %10d | %12.2f | %10.2f |\n",
aggreFunc[j][0] == '*' ? " * " : aggreFunc[j], totalData,
(double)(num_of_tables * num_of_DPT) / totalT, totalT * 1000);
- printf("select %10s took %.6f second(s)\n", aggreFunc[j], totalT);
+ printf("select %10s took %.6f second(s)\n", aggreFunc[j], totalT * 1000);
}
fprintf(fp, "\n");
fclose(fp);
@@ -5651,7 +5782,7 @@ static void *readMetric(void *sarg) {
printf("Where condition: %s\n", condition);
fprintf(fp, "%s\n", command);
- double t = getCurrentTimeUs();
+ double t = taosGetTimestampMs();
TAOS_RES *pSql = taos_query(taos, command);
int32_t code = taos_errno(pSql);
@@ -5667,11 +5798,11 @@ static void *readMetric(void *sarg) {
while(taos_fetch_row(pSql) != NULL) {
count++;
}
- t = getCurrentTimeUs() - t;
+ t = taosGetTimestampMs() - t;
fprintf(fp, "| Speed: %12.2f(per s) | Latency: %.4f(ms) |\n",
- num_of_tables * num_of_DPT / t, t * 1000);
- printf("select %10s took %.6f second(s)\n\n", aggreFunc[j], t);
+ num_of_tables * num_of_DPT / (t * 1000.0), t);
+ printf("select %10s took %.6f second(s)\n\n", aggreFunc[j], t * 1000.0);
taos_free_result(pSql);
}
@@ -5721,21 +5852,21 @@ static int insertTestProcess() {
double end;
// create child tables
- start = getCurrentTimeUs();
+ start = taosGetTimestampMs();
createChildTables();
- end = getCurrentTimeUs();
+ end = taosGetTimestampMs();
if (g_totalChildTables > 0) {
printf("Spent %.4f seconds to create %d tables with %d thread(s)\n\n",
- end - start, g_totalChildTables, g_Dbs.threadCountByCreateTbl);
+ (end - start)/1000.0, g_totalChildTables, g_Dbs.threadCountByCreateTbl);
fprintf(g_fpOfInsertResult,
"Spent %.4f seconds to create %d tables with %d thread(s)\n\n",
- end - start, g_totalChildTables, g_Dbs.threadCountByCreateTbl);
+ (end - start)/1000.0, g_totalChildTables, g_Dbs.threadCountByCreateTbl);
}
taosMsleep(1000);
// create sub threads for inserting data
- //start = getCurrentTimeUs();
+ //start = taosGetTimestampMs();
for (int i = 0; i < g_Dbs.dbCount; i++) {
if (g_Dbs.use_metric) {
if (g_Dbs.db[i].superTblCount > 0) {
@@ -5745,22 +5876,22 @@ static int insertTestProcess() {
if (superTblInfo && (superTblInfo->insertRows > 0)) {
startMultiThreadInsertData(
- g_Dbs.threadCount,
- g_Dbs.db[i].dbName,
- g_Dbs.db[i].dbCfg.precision,
- superTblInfo);
+ g_Dbs.threadCount,
+ g_Dbs.db[i].dbName,
+ g_Dbs.db[i].dbCfg.precision,
+ superTblInfo);
}
}
}
} else {
- startMultiThreadInsertData(
+ startMultiThreadInsertData(
g_Dbs.threadCount,
g_Dbs.db[i].dbName,
g_Dbs.db[i].dbCfg.precision,
NULL);
}
}
- //end = getCurrentTimeUs();
+ //end = taosGetTimestampMs();
//int64_t totalInsertRows = 0;
//int64_t totalAffectedRows = 0;
@@ -5781,13 +5912,13 @@ static void *specifiedTableQuery(void *sarg) {
if (pThreadInfo->taos == NULL) {
TAOS * taos = NULL;
taos = taos_connect(g_queryInfo.host,
- g_queryInfo.user,
- g_queryInfo.password,
- NULL,
- g_queryInfo.port);
+ g_queryInfo.user,
+ g_queryInfo.password,
+ NULL,
+ g_queryInfo.port);
if (taos == NULL) {
errorPrint("[%d] Failed to connect to TDengine, reason:%s\n",
- pThreadInfo->threadID, taos_errstr(NULL));
+ pThreadInfo->threadID, taos_errstr(NULL));
return NULL;
} else {
pThreadInfo->taos = taos;
@@ -5813,16 +5944,15 @@ static void *specifiedTableQuery(void *sarg) {
int64_t startTs = taosGetTimestampMs();
while(queryTimes --) {
- if (g_queryInfo.specifiedQueryInfo.rate && (et - st) <
- (int64_t)g_queryInfo.specifiedQueryInfo.rate*1000) {
- taosMsleep(g_queryInfo.specifiedQueryInfo.rate*1000 - (et - st)); // ms
- //printf("========sleep duration:%"PRId64 "========inserted rows:%d, table range:%d - %d\n", (1000 - (et - st)), i, pThreadInfo->start_table_from, pThreadInfo->end_table_to);
+ if (g_queryInfo.specifiedQueryInfo.queryInterval && (et - st) <
+ (int64_t)g_queryInfo.specifiedQueryInfo.queryInterval) {
+ taosMsleep(g_queryInfo.specifiedQueryInfo.queryInterval - (et - st)); // ms
}
- st = taosGetTimestampUs();
+ st = taosGetTimestampMs();
if (0 == strncasecmp(g_queryInfo.queryMode, "taosc", 5)) {
- int64_t t1 = taosGetTimestampUs();
+ int64_t t1 = taosGetTimestampMs();
char tmpFile[MAX_FILE_NAME_LEN*2] = {0};
if (g_queryInfo.specifiedQueryInfo.result[pThreadInfo->querySeq][0] != 0) {
sprintf(tmpFile, "%s-%d",
@@ -5830,38 +5960,39 @@ static void *specifiedTableQuery(void *sarg) {
pThreadInfo->threadID);
}
selectAndGetResult(pThreadInfo->taos,
- g_queryInfo.specifiedQueryInfo.sql[pThreadInfo->querySeq], tmpFile);
- int64_t t2 = taosGetTimestampUs();
- printf("=[taosc] thread[%"PRId64"] complete one sql, Spent %f s\n",
- taosGetSelfPthreadId(), (t2 - t1)/1000000.0);
+ g_queryInfo.specifiedQueryInfo.sql[pThreadInfo->querySeq], tmpFile);
+ int64_t t2 = taosGetTimestampMs();
+ printf("=[taosc] thread[%"PRId64"] complete one sql, Spent %10.3f s\n",
+ taosGetSelfPthreadId(), (t2 - t1)/1000.0);
} else {
- int64_t t1 = taosGetTimestampUs();
+ int64_t t1 = taosGetTimestampMs();
int retCode = postProceSql(g_queryInfo.host,
- g_queryInfo.port,
- g_queryInfo.specifiedQueryInfo.sql[pThreadInfo->querySeq]);
+ g_queryInfo.port,
+ g_queryInfo.specifiedQueryInfo.sql[pThreadInfo->querySeq]);
if (0 != retCode) {
printf("====restful return fail, threadID[%d]\n", pThreadInfo->threadID);
return NULL;
}
- int64_t t2 = taosGetTimestampUs();
- printf("=[restful] thread[%"PRId64"] complete one sql, Spent %f s\n",
- taosGetSelfPthreadId(), (t2 - t1)/1000000.0);
+ int64_t t2 = taosGetTimestampMs();
+ printf("=[restful] thread[%"PRId64"] complete one sql, Spent %10.3f s\n",
+ taosGetSelfPthreadId(), (t2 - t1)/1000.0);
}
totalQueried ++;
g_queryInfo.specifiedQueryInfo.totalQueried ++;
- et = taosGetTimestampUs();
- printf("==thread[%"PRId64"] complete all sqls to specify tables once queries duration:%.6fs\n\n",
- taosGetSelfPthreadId(), (double)(et - st)/1000.0);
+
+ et = taosGetTimestampMs();
int64_t currentPrintTime = taosGetTimestampMs();
int64_t endTs = taosGetTimestampMs();
if (currentPrintTime - lastPrintTime > 30*1000) {
- printf("thread[%d] has currently completed queries: %d, QPS: %10.2f\n",
+ debugPrint("%s() LN%d, endTs=%"PRId64"ms, startTs=%"PRId64"ms\n",
+ __func__, __LINE__, endTs, startTs);
+ printf("thread[%d] has currently completed queries: %d, QPS: %10.6f\n",
pThreadInfo->threadID,
totalQueried,
- totalQueried/((endTs-startTs)/1000.0));
+ (double)(totalQueried/((endTs-startTs)/1000.0)));
}
lastPrintTime = currentPrintTime;
}
@@ -5903,7 +6034,7 @@ static void *superTableQuery(void *sarg) {
g_queryInfo.port);
if (taos == NULL) {
errorPrint("[%d] Failed to connect to TDengine, reason:%s\n",
- pThreadInfo->threadID, taos_errstr(NULL));
+ pThreadInfo->threadID, taos_errstr(NULL));
return NULL;
} else {
pThreadInfo->taos = taos;
@@ -5911,7 +6042,7 @@ static void *superTableQuery(void *sarg) {
}
int64_t st = 0;
- int64_t et = (int64_t)g_queryInfo.superQueryInfo.rate*1000;
+ int64_t et = (int64_t)g_queryInfo.superQueryInfo.queryInterval;
int queryTimes = g_queryInfo.superQueryInfo.queryTimes;
int totalQueried = 0;
@@ -5919,13 +6050,13 @@ static void *superTableQuery(void *sarg) {
int64_t lastPrintTime = taosGetTimestampMs();
while(queryTimes --) {
- if (g_queryInfo.superQueryInfo.rate
- && (et - st) < (int64_t)g_queryInfo.superQueryInfo.rate*1000) {
- taosMsleep(g_queryInfo.superQueryInfo.rate*1000 - (et - st)); // ms
+ if (g_queryInfo.superQueryInfo.queryInterval
+ && (et - st) < (int64_t)g_queryInfo.superQueryInfo.queryInterval) {
+ taosMsleep(g_queryInfo.superQueryInfo.queryInterval - (et - st)); // ms
//printf("========sleep duration:%"PRId64 "========inserted rows:%d, table range:%d - %d\n", (1000 - (et - st)), i, pThreadInfo->start_table_from, pThreadInfo->end_table_to);
}
- st = taosGetTimestampUs();
+ st = taosGetTimestampMs();
for (int i = pThreadInfo->start_table_from; i <= pThreadInfo->end_table_to; i++) {
for (int j = 0; j < g_queryInfo.superQueryInfo.sqlCount; j++) {
memset(sqlstr,0,sizeof(sqlstr));
@@ -5944,20 +6075,20 @@ static void *superTableQuery(void *sarg) {
int64_t currentPrintTime = taosGetTimestampMs();
int64_t endTs = taosGetTimestampMs();
if (currentPrintTime - lastPrintTime > 30*1000) {
- printf("thread[%d] has currently completed queries: %d, QPS: %10.2f\n",
+ printf("thread[%d] has currently completed queries: %d, QPS: %10.3f\n",
pThreadInfo->threadID,
totalQueried,
- totalQueried/((endTs-startTs)/1000.0));
+ (double)(totalQueried/((endTs-startTs)/1000.0)));
}
lastPrintTime = currentPrintTime;
}
}
- et = taosGetTimestampUs();
+ et = taosGetTimestampMs();
printf("####thread[%"PRId64"] complete all sqls to allocate all sub-tables[%d - %d] once queries duration:%.4fs\n\n",
taosGetSelfPthreadId(),
pThreadInfo->start_table_from,
pThreadInfo->end_table_to,
- (double)(et - st)/1000000.0);
+ (double)(et - st)/1000.0);
}
return NULL;
@@ -6118,9 +6249,9 @@ static int queryTestProcess() {
int totalQueried = g_queryInfo.specifiedQueryInfo.totalQueried +
g_queryInfo.superQueryInfo.totalQueried;
- printf("==== completed total queries: %d, the QPS of all threads: %10.2f====\n",
+ printf("==== completed total queries: %d, the QPS of all threads: %10.3f====\n",
totalQueried,
- totalQueried/((endTs-startTs)/1000.0));
+ (double)(totalQueried/((endTs-startTs)/1000.0)));
return 0;
}
@@ -6190,8 +6321,8 @@ static void *superSubscribe(void *sarg) {
//int64_t st = 0;
//int64_t et = 0;
do {
- //if (g_queryInfo.specifiedQueryInfo.rate && (et - st) < g_queryInfo.specifiedQueryInfo.rate*1000) {
- // taosMsleep(g_queryInfo.specifiedQueryInfo.rate*1000 - (et - st)); // ms
+ //if (g_queryInfo.specifiedQueryInfo.queryInterval && (et - st) < g_queryInfo.specifiedQueryInfo.queryInterval) {
+ // taosMsleep(g_queryInfo.specifiedQueryInfo.queryInterval- (et - st)); // ms
// //printf("========sleep duration:%"PRId64 "========inserted rows:%d, table range:%d - %d\n", (1000 - (et - st)), i, pThreadInfo->start_table_from, pThreadInfo->end_table_to);
//}
@@ -6277,8 +6408,8 @@ static void *specifiedSubscribe(void *sarg) {
//int64_t st = 0;
//int64_t et = 0;
do {
- //if (g_queryInfo.specifiedQueryInfo.rate && (et - st) < g_queryInfo.specifiedQueryInfo.rate*1000) {
- // taosMsleep(g_queryInfo.specifiedQueryInfo.rate*1000 - (et - st)); // ms
+ //if (g_queryInfo.specifiedQueryInfo.queryInterval && (et - st) < g_queryInfo.specifiedQueryInfo.queryInterval) {
+ // taosMsleep(g_queryInfo.specifiedQueryInfo.queryInterval- (et - st)); // ms
// //printf("========sleep duration:%"PRId64 "========inserted rows:%d, table range:%d - %d\n", (1000 - (et - st)), i, pThreadInfo->start_table_from, pThreadInfo->end_table_to);
//}
@@ -6628,7 +6759,7 @@ static void querySqlFile(TAOS* taos, char* sqlFile)
char * line = NULL;
size_t line_len = 0;
- double t = getCurrentTimeUs();
+ double t = taosGetTimestampMs();
while((read_len = tgetline(&line, &line_len, fp)) != -1) {
if (read_len >= MAX_SQL_SIZE) continue;
@@ -6659,7 +6790,7 @@ static void querySqlFile(TAOS* taos, char* sqlFile)
cmd_len = 0;
}
- t = getCurrentTimeUs() - t;
+ t = taosGetTimestampMs() - t;
printf("run %s took %.6f second(s)\n\n", sqlFile, t);
tmfree(cmd);
diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c
index 092374cef1..96a1cd16f8 100644
--- a/src/kit/taosdump/taosdump.c
+++ b/src/kit/taosdump/taosdump.c
@@ -214,8 +214,8 @@ static struct argp_option options[] = {
// dump format options
{"schemaonly", 's', 0, 0, "Only dump schema.", 3},
{"with-property", 'M', 0, 0, "Dump schema with properties.", 3},
- {"start-time", 'S', "START_TIME", 0, "Start time to dump.", 3},
- {"end-time", 'E', "END_TIME", 0, "End time to dump. Epoch or ISO8601/RFC3339 format is acceptable. For example: 2017-10-01T18:00:00+0800", 3},
+ {"start-time", 'S', "START_TIME", 0, "Start time to dump. Either Epoch or ISO8601/RFC3339 format is acceptable. Epoch precision millisecond. ISO8601 format example: 2017-10-01T18:00:00.000+0800 or 2017-10-0100:00:00.000+0800 or '2017-10-01 00:00:00.000+0800'", 3},
+ {"end-time", 'E', "END_TIME", 0, "End time to dump. Either Epoch or ISO8601/RFC3339 format is acceptable. Epoch precision millisecond. ISO8601 format example: 2017-10-01T18:00:00.000+0800 or 2017-10-0100:00:00.000+0800 or '2017-10-01 00:00:00.000+0800'", 3},
{"data-batch", 'N', "DATA_BATCH", 0, "Number of data point per insert statement. Default is 1.", 3},
{"max-sql-len", 'L', "SQL_LEN", 0, "Max length of one sql. Default is 65480.", 3},
{"table-batch", 't', "TABLE_BATCH", 0, "Number of table dumpout into one output file. Default is 1.", 3},
@@ -482,7 +482,8 @@ static int queryDbImpl(TAOS *taos, char *command) {
static void parse_args(int argc, char *argv[], SArguments *arguments) {
for (int i = 1; i < argc; i++) {
- if (strcmp(argv[i], "-E") == 0) {
+ if ((strcmp(argv[i], "-S") == 0)
+ || (strcmp(argv[i], "-E") == 0)) {
if (argv[i+1]) {
char *tmp = strdup(argv[++i]);
@@ -509,7 +510,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
exit(-1);
}
} else {
- errorPrint("%s() LN%d, -E need a valid value following!\n", __func__, __LINE__);
+ errorPrint("%s need a valid value following!\n", argv[i]);
exit(-1);
}
} else if (strcmp(argv[i], "-g") == 0) {
@@ -522,7 +523,8 @@ int main(int argc, char *argv[]) {
/* Parse our arguments; every option seen by parse_opt will be
reflected in arguments. */
- parse_args(argc, argv, &g_args);
+ if (argc > 1)
+ parse_args(argc, argv, &g_args);
argp_parse(&argp, argc, argv, 0, 0, &g_args);
diff --git a/src/os/inc/os.h b/src/os/inc/os.h
index 8312b74a50..c3e02b14db 100644
--- a/src/os/inc/os.h
+++ b/src/os/inc/os.h
@@ -32,6 +32,10 @@ extern "C" {
#include "osArm32.h"
#endif
+#ifdef _TD_MIPS_64
+#include "osMips64.h"
+#endif
+
#ifdef _TD_LINUX_64
#include "osLinux64.h"
#endif
diff --git a/src/os/inc/osMips64.h b/src/os/inc/osMips64.h
new file mode 100644
index 0000000000..ed7b08a311
--- /dev/null
+++ b/src/os/inc/osMips64.h
@@ -0,0 +1,87 @@
+/*
+ * 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_OS_MIPS64_H
+#define TDENGINE_OS_MIPS64_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/os/src/darwin/darwinSysInfo.c b/src/os/src/darwin/darwinSysInfo.c
index 55c07766b3..6e70043779 100644
--- a/src/os/src/darwin/darwinSysInfo.c
+++ b/src/os/src/darwin/darwinSysInfo.c
@@ -217,7 +217,7 @@ void taosSetCoreDump() {}
int32_t taosGetDiskSize(char *dataDir, SysDiskSize *diskSize) {
struct statvfs info;
- if (statvfs(tsDataDir, &info)) {
+ if (statvfs(dataDir, &info)) {
uError("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
terrno = TAOS_SYSTEM_ERROR(errno);
return -1;
diff --git a/src/os/src/detail/osSysinfo.c b/src/os/src/detail/osSysinfo.c
index c0d46878a8..bbda08aa25 100644
--- a/src/os/src/detail/osSysinfo.c
+++ b/src/os/src/detail/osSysinfo.c
@@ -319,7 +319,7 @@ bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
int32_t taosGetDiskSize(char *dataDir, SysDiskSize *diskSize) {
struct statvfs info;
- if (statvfs(tsDataDir, &info)) {
+ if (statvfs(dataDir, &info)) {
uError("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
terrno = TAOS_SYSTEM_ERROR(errno);
return -1;
diff --git a/src/plugins/http/inc/httpContext.h b/src/plugins/http/inc/httpContext.h
index b016da2dd3..af52fdd1eb 100644
--- a/src/plugins/http/inc/httpContext.h
+++ b/src/plugins/http/inc/httpContext.h
@@ -25,7 +25,7 @@ const char *httpContextStateStr(HttpContextState state);
HttpContext *httpCreateContext(SOCKET fd);
bool httpInitContext(HttpContext *pContext);
HttpContext *httpGetContext(void * pContext);
-void httpReleaseContext(HttpContext *pContext, bool clearRes);
+void httpReleaseContext(HttpContext *pContext/*, bool clearRes*/);
void httpCloseContextByServer(HttpContext *pContext);
void httpCloseContextByApp(HttpContext *pContext);
void httpNotifyContextClose(HttpContext *pContext);
diff --git a/src/plugins/http/src/httpContext.c b/src/plugins/http/src/httpContext.c
index 13f706af65..51adef11b9 100644
--- a/src/plugins/http/src/httpContext.c
+++ b/src/plugins/http/src/httpContext.c
@@ -146,20 +146,20 @@ HttpContext *httpGetContext(void *ptr) {
return NULL;
}
-void httpReleaseContext(HttpContext *pContext, bool clearRes) {
+void httpReleaseContext(HttpContext *pContext/*, bool clearRes*/) {
int32_t refCount = atomic_sub_fetch_32(&pContext->refCount, 1);
if (refCount < 0) {
httpError("context:%p, is already released, refCount:%d", pContext, refCount);
return;
}
-
+ /*
if (clearRes) {
if (pContext->parser) {
httpClearParser(pContext->parser);
}
memset(&pContext->singleCmd, 0, sizeof(HttpSqlCmd));
}
-
+ */
HttpContext **ppContext = pContext->ppContext;
httpTrace("context:%p, is released, data:%p refCount:%d", pContext, ppContext, refCount);
@@ -217,7 +217,7 @@ void httpCloseContextByApp(HttpContext *pContext) {
httpContextStateStr(pContext->state), pContext->state);
}
- httpReleaseContext(pContext, true);
+ httpReleaseContext(pContext/*, true*/);
}
void httpCloseContextByServer(HttpContext *pContext) {
@@ -235,5 +235,5 @@ void httpCloseContextByServer(HttpContext *pContext) {
pContext->parsed = false;
httpRemoveContextFromEpoll(pContext);
- httpReleaseContext(pContext, true);
+ httpReleaseContext(pContext/*, true*/);
}
diff --git a/src/plugins/http/src/httpHandle.c b/src/plugins/http/src/httpHandle.c
index ad79e24061..d51c774ff2 100644
--- a/src/plugins/http/src/httpHandle.c
+++ b/src/plugins/http/src/httpHandle.c
@@ -50,6 +50,7 @@ bool httpProcessData(HttpContext* pContext) {
*/
// httpCloseContextByApp(pContext);
} else {
+ httpClearParser(pContext->parser);
httpProcessRequest(pContext);
}
}
diff --git a/src/plugins/http/src/httpServer.c b/src/plugins/http/src/httpServer.c
index a5f40fdc4c..4dcf3d5501 100644
--- a/src/plugins/http/src/httpServer.c
+++ b/src/plugins/http/src/httpServer.c
@@ -177,7 +177,7 @@ static void httpProcessHttpData(void *param) {
if (!httpAlterContextState(pContext, HTTP_CONTEXT_STATE_READY, HTTP_CONTEXT_STATE_READY)) {
httpDebug("context:%p, fd:%d, state:%s, not in ready state, ignore read events", pContext, pContext->fd,
httpContextStateStr(pContext->state));
- httpReleaseContext(pContext, true);
+ httpReleaseContext(pContext/*, true*/);
continue;
}
@@ -191,7 +191,7 @@ static void httpProcessHttpData(void *param) {
(*(pThread->processData))(pContext);
atomic_fetch_add_32(&pServer->requestNum, 1);
} else {
- httpReleaseContext(pContext, false);
+ httpReleaseContext(pContext/*, false*/);
}
}
}
@@ -275,7 +275,7 @@ static void *httpAcceptHttpConnection(void *arg) {
httpError("context:%p, fd:%d, ip:%s, thread:%s, failed to add http fd for epoll, error:%s", pContext, connFd,
pContext->ipstr, pThread->label, strerror(errno));
taosCloseSocket(pContext->fd);
- httpReleaseContext(pContext, true);
+ httpReleaseContext(pContext/*, true*/);
continue;
}
diff --git a/src/plugins/http/src/httpSql.c b/src/plugins/http/src/httpSql.c
index 4e9b54b7bd..b345c1531f 100644
--- a/src/plugins/http/src/httpSql.c
+++ b/src/plugins/http/src/httpSql.c
@@ -376,6 +376,8 @@ void httpExecCmd(HttpContext *pContext) {
httpCloseContextByApp(pContext);
break;
}
+
+ memset(&pContext->singleCmd, 0, sizeof(HttpSqlCmd));
}
void httpProcessRequestCb(void *param, TAOS_RES *result, int32_t code) {
diff --git a/src/query/inc/qSqlparser.h b/src/query/inc/qSqlparser.h
index 63dc7b3761..85cba06b3e 100644
--- a/src/query/inc/qSqlparser.h
+++ b/src/query/inc/qSqlparser.h
@@ -44,6 +44,12 @@ enum SQL_NODE_FROM_TYPE {
SQL_NODE_FROM_TABLELIST = 2,
};
+enum SQL_EXPR_FLAG {
+ EXPR_FLAG_TS_ERROR = 1,
+ EXPR_FLAG_US_TIMESTAMP = 2,
+ EXPR_FLAG_TIMESTAMP_VAR = 3,
+};
+
extern char tTokenTypeSwitcher[13];
#define toTSDBType(x) \
@@ -229,7 +235,8 @@ typedef struct tSqlExpr {
SStrToken colInfo; // table column info
tVariant value; // the use input value
SStrToken token; // original sql expr string
-
+ uint32_t flags;
+
struct tSqlExpr *pLeft; // left child
struct tSqlExpr *pRight; // right child
struct SArray *pParam; // function parameters list
diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y
index 8ca0dee2d6..fd922240c2 100644
--- a/src/query/inc/sql.y
+++ b/src/query/inc/sql.y
@@ -669,6 +669,8 @@ expr(A) ::= PLUS(X) FLOAT(Y). { X.n += Y.n; X.type = TK_FLOAT; A = tSqlExprCr
expr(A) ::= STRING(X). { A = tSqlExprCreateIdValue(&X, TK_STRING);}
expr(A) ::= NOW(X). { A = tSqlExprCreateIdValue(&X, TK_NOW); }
expr(A) ::= VARIABLE(X). { A = tSqlExprCreateIdValue(&X, TK_VARIABLE);}
+expr(A) ::= PLUS(X) VARIABLE(Y). { X.n += Y.n; X.type = TK_VARIABLE; A = tSqlExprCreateIdValue(&X, TK_VARIABLE);}
+expr(A) ::= MINUS(X) VARIABLE(Y). { X.n += Y.n; X.type = TK_VARIABLE; A = tSqlExprCreateIdValue(&X, TK_VARIABLE);}
expr(A) ::= BOOL(X). { A = tSqlExprCreateIdValue(&X, TK_BOOL);}
expr(A) ::= NULL(X). { A = tSqlExprCreateIdValue(&X, TK_NULL);}
diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c
index 53555d90d4..11a96f7ef3 100644
--- a/src/query/src/qAggMain.c
+++ b/src/query/src/qAggMain.c
@@ -2476,6 +2476,29 @@ static STopBotInfo *getTopBotOutputInfo(SQLFunctionCtx *pCtx) {
}
}
+
+/*
+ * keep the intermediate results during scan data blocks in the format of:
+ * +-----------------------------------+-------------one value pair-----------+------------next value pair-----------+
+ * |-------------pointer area----------|----ts---+-----+-----n tags-----------|----ts---+-----+-----n tags-----------|
+ * +..[Value Pointer1][Value Pointer2].|timestamp|value|tags1|tags2|....|tagsn|timestamp|value|tags1|tags2|....|tagsn+
+ */
+static void buildTopBotStruct(STopBotInfo *pTopBotInfo, SQLFunctionCtx *pCtx) {
+ char *tmp = (char *)pTopBotInfo + sizeof(STopBotInfo);
+ pTopBotInfo->res = (tValuePair**) tmp;
+ tmp += POINTER_BYTES * pCtx->param[0].i64;
+
+ size_t size = sizeof(tValuePair) + pCtx->tagInfo.tagsLen;
+// assert(pCtx->param[0].i64 > 0);
+
+ for (int32_t i = 0; i < pCtx->param[0].i64; ++i) {
+ pTopBotInfo->res[i] = (tValuePair*) tmp;
+ pTopBotInfo->res[i]->pTags = tmp + sizeof(tValuePair);
+ tmp += size;
+ }
+}
+
+
bool topbot_datablock_filter(SQLFunctionCtx *pCtx, const char *minval, const char *maxval) {
SResultRowCellInfo *pResInfo = GET_RES_INFO(pCtx);
if (pResInfo == NULL) {
@@ -2489,6 +2512,10 @@ bool topbot_datablock_filter(SQLFunctionCtx *pCtx, const char *minval, const cha
return true;
}
+ if ((void *)pTopBotInfo->res[0] != (void *)((char *)pTopBotInfo + sizeof(STopBotInfo) + POINTER_BYTES * pCtx->param[0].i64)) {
+ buildTopBotStruct(pTopBotInfo, pCtx);
+ }
+
tValuePair **pRes = (tValuePair**) pTopBotInfo->res;
if (pCtx->functionId == TSDB_FUNC_TOP) {
@@ -2528,27 +2555,6 @@ bool topbot_datablock_filter(SQLFunctionCtx *pCtx, const char *minval, const cha
}
}
-/*
- * keep the intermediate results during scan data blocks in the format of:
- * +-----------------------------------+-------------one value pair-----------+------------next value pair-----------+
- * |-------------pointer area----------|----ts---+-----+-----n tags-----------|----ts---+-----+-----n tags-----------|
- * +..[Value Pointer1][Value Pointer2].|timestamp|value|tags1|tags2|....|tagsn|timestamp|value|tags1|tags2|....|tagsn+
- */
-static void buildTopBotStruct(STopBotInfo *pTopBotInfo, SQLFunctionCtx *pCtx) {
- char *tmp = (char *)pTopBotInfo + sizeof(STopBotInfo);
- pTopBotInfo->res = (tValuePair**) tmp;
- tmp += POINTER_BYTES * pCtx->param[0].i64;
-
- size_t size = sizeof(tValuePair) + pCtx->tagInfo.tagsLen;
-// assert(pCtx->param[0].i64 > 0);
-
- for (int32_t i = 0; i < pCtx->param[0].i64; ++i) {
- pTopBotInfo->res[i] = (tValuePair*) tmp;
- pTopBotInfo->res[i]->pTags = tmp + sizeof(tValuePair);
- tmp += size;
- }
-}
-
static bool top_bottom_function_setup(SQLFunctionCtx *pCtx) {
if (!function_setup(pCtx)) {
return false;
@@ -2603,6 +2609,10 @@ static void top_function_f(SQLFunctionCtx *pCtx, int32_t index) {
STopBotInfo *pRes = getTopBotOutputInfo(pCtx);
assert(pRes->num >= 0);
+
+ if ((void *)pRes->res[0] != (void *)((char *)pRes + sizeof(STopBotInfo) + POINTER_BYTES * pCtx->param[0].i64)) {
+ buildTopBotStruct(pRes, pCtx);
+ }
SET_VAL(pCtx, 1, 1);
TSKEY ts = GET_TS_DATA(pCtx, index);
diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c
index f44edf7503..13265c7300 100644
--- a/src/query/src/qExecutor.c
+++ b/src/query/src/qExecutor.c
@@ -1272,7 +1272,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SGroupbyOperatorInfo *pIn
int16_t type = pColInfoData->info.type;
if (type == TSDB_DATA_TYPE_FLOAT || type == TSDB_DATA_TYPE_DOUBLE) {
- qError("QInfo:%"PRIu64" group by not supported on double/float columns, abort", GET_QID(pRuntimeEnv));
+ qError("QInfo:0x%"PRIx64" group by not supported on double/float columns, abort", GET_QID(pRuntimeEnv));
return;
}
@@ -1659,7 +1659,7 @@ static void* destroySQLFunctionCtx(SQLFunctionCtx* pCtx, int32_t numOfOutput) {
}
static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOfTables, SArray* pOperator, void* merger) {
- qDebug("QInfo:%"PRIu64" setup runtime env", GET_QID(pRuntimeEnv));
+ qDebug("QInfo:0x%"PRIx64" setup runtime env", GET_QID(pRuntimeEnv));
SQueryAttr *pQueryAttr = pRuntimeEnv->pQueryAttr;
pRuntimeEnv->prevGroupId = INT32_MIN;
@@ -1692,7 +1692,7 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf
*(int64_t*) pRuntimeEnv->prevRow[0] = INT64_MIN;
}
- qDebug("QInfo:%"PRIu64" init runtime environment completed", GET_QID(pRuntimeEnv));
+ qDebug("QInfo:0x%"PRIx64" init runtime environment completed", GET_QID(pRuntimeEnv));
// group by normal column, sliding window query, interval query are handled by interval query processor
// interval (down sampling operation)
@@ -1832,12 +1832,14 @@ static void doFreeQueryHandle(SQueryRuntimeEnv* pRuntimeEnv) {
}
static void destroyTsComp(SQueryRuntimeEnv *pRuntimeEnv, SQueryAttr *pQueryAttr) {
- if (pQueryAttr->tsCompQuery) {
+ if (pQueryAttr->tsCompQuery && pRuntimeEnv->outputBuf && pRuntimeEnv->outputBuf->pDataBlock && taosArrayGetSize(pRuntimeEnv->outputBuf->pDataBlock) > 0) {
SColumnInfoData* pColInfoData = taosArrayGet(pRuntimeEnv->outputBuf->pDataBlock, 0);
- FILE *f = *(FILE **)pColInfoData->pData; // TODO refactor
- if (f) {
- fclose(f);
- *(FILE **)pColInfoData->pData = NULL;
+ if (pColInfoData) {
+ FILE *f = *(FILE **)pColInfoData->pData; // TODO refactor
+ if (f) {
+ fclose(f);
+ *(FILE **)pColInfoData->pData = NULL;
+ }
}
}
}
@@ -1846,7 +1848,7 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
SQueryAttr *pQueryAttr = pRuntimeEnv->pQueryAttr;
SQInfo* pQInfo = (SQInfo*) pRuntimeEnv->qinfo;
- qDebug("QInfo:%"PRIu64" teardown runtime env", pQInfo->qId);
+ qDebug("QInfo:0x%"PRIx64" teardown runtime env", pQInfo->qId);
if (pRuntimeEnv->sasArray != NULL) {
for(int32_t i = 0; i < pQueryAttr->numOfOutput; ++i) {
@@ -2019,7 +2021,7 @@ bool colIdCheck(SQueryAttr *pQueryAttr, uint64_t qId) {
// load data column information is incorrect
for (int32_t i = 0; i < pQueryAttr->numOfCols - 1; ++i) {
if (pQueryAttr->tableCols[i].colId == pQueryAttr->tableCols[i + 1].colId) {
- qError("QInfo:%"PRIu64" invalid data load column for query", qId);
+ qError("QInfo:0x%"PRIx64" invalid data load column for query", qId);
return false;
}
}
@@ -2106,14 +2108,13 @@ static void changeExecuteScanOrder(SQInfo *pQInfo, SQueryTableMsg* pQueryMsg, bo
SQueryAttr* pQueryAttr = pQInfo->runtimeEnv.pQueryAttr;
// in case of point-interpolation query, use asc order scan
- char msg[] = "QInfo:%"PRIu64" scan order changed for %s query, old:%d, new:%d, qrange exchanged, old qrange:%" PRId64
+ char msg[] = "QInfo:0x%"PRIx64" scan order changed for %s query, old:%d, new:%d, qrange exchanged, old qrange:%" PRId64
"-%" PRId64 ", new qrange:%" PRId64 "-%" PRId64;
// todo handle the case the the order irrelevant query type mixed up with order critical query type
// descending order query for last_row query
if (isFirstLastRowQuery(pQueryAttr)) {
- qDebug("QInfo:%"PRIu64" scan order changed for last_row query, old:%d, new:%d", pQInfo->qId,
- pQueryAttr->order.order, TSDB_ORDER_ASC);
+ qDebug("QInfo:0x%"PRIx64" scan order changed for last_row query, old:%d, new:%d", pQInfo->qId, pQueryAttr->order.order, TSDB_ORDER_ASC);
pQueryAttr->order.order = TSDB_ORDER_ASC;
if (pQueryAttr->window.skey > pQueryAttr->window.ekey) {
@@ -2590,7 +2591,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa
*status = updateBlockLoadStatus(pRuntimeEnv->pQueryAttr, *status);
if ((*status) == BLK_DATA_NO_NEEDED || (*status) == BLK_DATA_DISCARD) {
- qDebug("QInfo:%"PRIu64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey,
+ qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey,
pBlockInfo->window.ekey, pBlockInfo->rows);
pCost->discardBlocks += 1;
} else if ((*status) == BLK_DATA_STATIS_NEEDED) {
@@ -2633,7 +2634,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa
(char*)&(pBlock->pBlockStatis[i].max));
if (!load) { // current block has been discard due to filter applied
pCost->discardBlocks += 1;
- qDebug("QInfo:%"PRIu64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId,
+ qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId,
pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
(*status) = BLK_DATA_DISCARD;
return TSDB_CODE_SUCCESS;
@@ -2645,7 +2646,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa
// current block has been discard due to filter applied
if (!doFilterByBlockStatistics(pRuntimeEnv, pBlock->pBlockStatis, pTableScanInfo->pCtx, pBlockInfo->rows)) {
pCost->discardBlocks += 1;
- qDebug("QInfo:%"PRIu64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey,
+ qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey,
pBlockInfo->window.ekey, pBlockInfo->rows);
(*status) = BLK_DATA_DISCARD;
return TSDB_CODE_SUCCESS;
@@ -3313,10 +3314,10 @@ void setCtxTagForJoin(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx, SExpr
int16_t tagType = pCtx[0].tag.nType;
if (tagType == TSDB_DATA_TYPE_BINARY || tagType == TSDB_DATA_TYPE_NCHAR) {
- qDebug("QInfo:%p set tag value for join comparison, colId:%" PRId64 ", val:%s", pRuntimeEnv->qinfo,
+ qDebug("QInfo:0x%"PRIx64" set tag value for join comparison, colId:%" PRId64 ", val:%s", GET_QID(pRuntimeEnv),
pExprInfo->base.param[0].i64, pCtx[0].tag.pz);
} else {
- qDebug("QInfo:%p set tag value for join comparison, colId:%" PRId64 ", val:%" PRId64, pRuntimeEnv->qinfo,
+ qDebug("QInfo:0x%"PRIx64" set tag value for join comparison, colId:%" PRId64 ", val:%" PRId64, GET_QID(pRuntimeEnv),
pExprInfo->base.param[0].i64, pCtx[0].tag.i64);
}
}
@@ -3336,9 +3337,9 @@ int32_t setTimestampListJoinInfo(SQueryRuntimeEnv* pRuntimeEnv, tVariant* pTag,
// failed to find data with the specified tag value and vnodeId
if (!tsBufIsValidElem(&elem)) {
if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) {
- qError("QInfo:%"PRIu64" failed to find tag:%s in ts_comp", GET_QID(pRuntimeEnv), pTag->pz);
+ qError("QInfo:0x%"PRIx64" failed to find tag:%s in ts_comp", GET_QID(pRuntimeEnv), pTag->pz);
} else {
- qError("QInfo:%"PRIu64" failed to find tag:%" PRId64 " in ts_comp", GET_QID(pRuntimeEnv), pTag->i64);
+ qError("QInfo:0x%"PRIx64" failed to find tag:%" PRId64 " in ts_comp", GET_QID(pRuntimeEnv), pTag->i64);
}
return -1;
@@ -3347,17 +3348,17 @@ int32_t setTimestampListJoinInfo(SQueryRuntimeEnv* pRuntimeEnv, tVariant* pTag,
// Keep the cursor info of current table
pTableQueryInfo->cur = tsBufGetCursor(pRuntimeEnv->pTsBuf);
if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) {
- qDebug("QInfo:%"PRIu64" find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d", GET_QID(pRuntimeEnv), pTag->pz, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex);
+ qDebug("QInfo:0x%"PRIx64" find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d", GET_QID(pRuntimeEnv), pTag->pz, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex);
} else {
- qDebug("QInfo:%"PRIu64" find tag:%"PRId64" start pos in ts_comp, blockIndex:%d, tsIndex:%d", GET_QID(pRuntimeEnv), pTag->i64, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex);
+ qDebug("QInfo:0x%"PRIx64" find tag:%"PRId64" start pos in ts_comp, blockIndex:%d, tsIndex:%d", GET_QID(pRuntimeEnv), pTag->i64, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex);
}
} else {
tsBufSetCursor(pRuntimeEnv->pTsBuf, &pTableQueryInfo->cur);
if (pTag->nType == TSDB_DATA_TYPE_BINARY || pTag->nType == TSDB_DATA_TYPE_NCHAR) {
- qDebug("QInfo:%"PRIu64" find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d", GET_QID(pRuntimeEnv), pTag->pz, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex);
+ qDebug("QInfo:0x%"PRIx64" find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d", GET_QID(pRuntimeEnv), pTag->pz, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex);
} else {
- qDebug("QInfo:%"PRIu64" find tag:%"PRId64" start pos in ts_comp, blockIndex:%d, tsIndex:%d", GET_QID(pRuntimeEnv), pTag->i64, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex);
+ qDebug("QInfo:0x%"PRIx64" find tag:%"PRId64" start pos in ts_comp, blockIndex:%d, tsIndex:%d", GET_QID(pRuntimeEnv), pTag->i64, pTableQueryInfo->cur.blockIndex, pTableQueryInfo->cur.tsIndex);
}
}
@@ -3492,7 +3493,7 @@ static int32_t doCopyToSDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SGroupResInfo*
int32_t start = 0;
int32_t step = -1;
- qDebug("QInfo:%"PRIu64" start to copy data from windowResInfo to output buf", GET_QID(pRuntimeEnv));
+ qDebug("QInfo:0x%"PRIx64" start to copy data from windowResInfo to output buf", GET_QID(pRuntimeEnv));
if (orderType == TSDB_ORDER_ASC) {
start = pGroupResInfo->index;
step = 1;
@@ -3532,7 +3533,7 @@ static int32_t doCopyToSDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SGroupResInfo*
}
}
- qDebug("QInfo:%"PRIu64" copy data to query buf completed", GET_QID(pRuntimeEnv));
+ qDebug("QInfo:0x%"PRIx64" copy data to query buf completed", GET_QID(pRuntimeEnv));
pBlock->info.rows = numOfResult;
return 0;
}
@@ -3619,11 +3620,11 @@ static void doCopyQueryResultToMsg(SQInfo *pQInfo, int32_t numOfRows, char *data
data += sizeof(STableIdInfo);
total++;
- qDebug("QInfo:%"PRIu64" set subscribe info, tid:%d, uid:%"PRIu64", skey:%"PRId64, pQInfo->qId, item->tid, item->uid, item->key);
+ qDebug("QInfo:0x%"PRIx64" set subscribe info, tid:%d, uid:%"PRIu64", skey:%"PRId64, pQInfo->qId, item->tid, item->uid, item->key);
item = taosHashIterate(pRuntimeEnv->pTableRetrieveTsMap, item);
}
- qDebug("QInfo:%"PRIu64" set %d subscribe info", pQInfo->qId, total);
+ qDebug("QInfo:0x%"PRIx64" set %d subscribe info", pQInfo->qId, total);
// Check if query is completed or not for stable query or normal table query respectively.
if (Q_STATUS_EQUAL(pRuntimeEnv->status, QUERY_COMPLETED) && pRuntimeEnv->proot->status == OP_EXEC_DONE) {
setQueryStatus(pRuntimeEnv, QUERY_OVER);
@@ -3662,12 +3663,12 @@ void queryCostStatis(SQInfo *pQInfo) {
pSummary->numOfTimeWindows = 0;
}
- qDebug("QInfo:%"PRIu64" :cost summary: elapsed time:%"PRId64" us, first merge:%"PRId64" us, total blocks:%d, "
+ qDebug("QInfo:0x%"PRIx64" :cost summary: elapsed time:%"PRId64" us, first merge:%"PRId64" us, total blocks:%d, "
"load block statis:%d, load data block:%d, total rows:%"PRId64 ", check rows:%"PRId64,
pQInfo->qId, pSummary->elapsedTime, pSummary->firstStageMergeTime, pSummary->totalBlocks, pSummary->loadBlockStatis,
pSummary->loadBlocks, pSummary->totalRows, pSummary->totalCheckedRows);
- qDebug("QInfo:%"PRIu64" :cost summary: winResPool size:%.2f Kb, numOfWin:%"PRId64", tableInfoSize:%.2f Kb, hashTable:%.2f Kb", pQInfo->qId, pSummary->winInfoSize/1024.0,
+ qDebug("QInfo:0x%"PRIx64" :cost summary: winResPool size:%.2f Kb, numOfWin:%"PRId64", tableInfoSize:%.2f Kb, hashTable:%.2f Kb", pQInfo->qId, pSummary->winInfoSize/1024.0,
pSummary->numOfTimeWindows, pSummary->tableInfoSize/1024.0, pSummary->hashSize/1024.0);
}
@@ -3703,8 +3704,8 @@ void queryCostStatis(SQInfo *pQInfo) {
//
// int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, pBlockInfo, NULL, binarySearchForKey, pDataBlock);
//
-// qDebug("QInfo:%"PRIu64" check data block, brange:%" PRId64 "-%" PRId64 ", numOfRows:%d, numOfRes:%d, lastKey:%"PRId64, GET_QID(pRuntimeEnv),
-// pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, numOfRes, pQueryAttr->current->lastKey);
+// qDebug("QInfo:0x%"PRIx64" check data block, brange:%" PRId64 "-%" PRId64 ", numOfRows:%d, numOfRes:%d, lastKey:%"PRId64, GET_QID(pRuntimeEnv),
+// pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, numOfRes, pQuery->current->lastKey);
//}
//void skipBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
@@ -3733,8 +3734,8 @@ void queryCostStatis(SQInfo *pQInfo) {
// pTableQueryInfo->lastKey = (QUERY_IS_ASC_QUERY(pQueryAttr)) ? blockInfo.window.ekey : blockInfo.window.skey;
// pTableQueryInfo->lastKey += step;
//
-// qDebug("QInfo:%"PRIu64" skip rows:%d, offset:%" PRId64, GET_QID(pRuntimeEnv), blockInfo.rows,
-// pQueryAttr->limit.offset);
+// qDebug("QInfo:0x%"PRIx64" skip rows:%d, offset:%" PRId64, GET_QID(pRuntimeEnv), blockInfo.rows,
+// pQuery->limit.offset);
// } else { // find the appropriated start position in current block
// updateOffsetVal(pRuntimeEnv, &blockInfo);
// break;
@@ -3781,7 +3782,7 @@ void queryCostStatis(SQInfo *pQInfo) {
// int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, pBlockInfo, NULL, binarySearchForKey, pDataBlock);
// pRuntimeEnv->resultRowInfo.curIndex = index; // restore the window index
//
-// qDebug("QInfo:%"PRIu64" check data block, brange:%" PRId64 "-%" PRId64 ", numOfRows:%d, numOfRes:%d, lastKey:%" PRId64,
+// qDebug("QInfo:0x%"PRIx64" check data block, brange:%" PRId64 "-%" PRId64 ", numOfRows:%d, numOfRes:%d, lastKey:%" PRId64,
// GET_QID(pRuntimeEnv), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, numOfRes,
// pQueryAttr->current->lastKey);
//
@@ -4225,7 +4226,7 @@ static SSDataBlock* doTableScan(void* param, bool *newgroup) {
pResultRowInfo->prevSKey = pResultRowInfo->pResult[0]->win.skey;
}
- qDebug("QInfo:%"PRIu64" start to repeat scan data blocks due to query func required, qrange:%" PRId64 "-%" PRId64,
+ qDebug("QInfo:0x%"PRIx64" start to repeat scan data blocks due to query func required, qrange:%" PRId64 "-%" PRId64,
GET_QID(pRuntimeEnv), cond.twindow.skey, cond.twindow.ekey);
}
@@ -4236,7 +4237,7 @@ static SSDataBlock* doTableScan(void* param, bool *newgroup) {
STsdbQueryCond cond = createTsdbQueryCond(pQueryAttr, &pQueryAttr->window);
tsdbResetQueryHandle(pTableScanInfo->pQueryHandle, &cond);
- qDebug("QInfo:%"PRIu64" start to reverse scan data blocks due to query func required, qrange:%" PRId64 "-%" PRId64,
+ qDebug("QInfo:0x%"PRIx64" start to reverse scan data blocks due to query func required, qrange:%" PRId64 "-%" PRId64,
GET_QID(pRuntimeEnv), cond.twindow.skey, cond.twindow.ekey);
pRuntimeEnv->scanFlag = REVERSE_SCAN;
@@ -5714,14 +5715,14 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) {
count += 1;
}
- qDebug("QInfo:%"PRIu64" create (tableId, tag) info completed, rows:%d", GET_QID(pRuntimeEnv), count);
+ qDebug("QInfo:0x%"PRIx64" create (tableId, tag) info completed, rows:%d", GET_QID(pRuntimeEnv), count);
} else if (functionId == TSDB_FUNC_COUNT) {// handle the "count(tbname)" query
SColumnInfoData* pColInfo = taosArrayGet(pRes->pDataBlock, 0);
*(int64_t*)pColInfo->pData = pInfo->totalTables;
count = 1;
pOperator->status = OP_EXEC_DONE;
- qDebug("QInfo:%"PRIu64" create count(tbname) query, res:%d rows:1", GET_QID(pRuntimeEnv), count);
+ qDebug("QInfo:0x%"PRIx64" create count(tbname) query, res:%d rows:1", GET_QID(pRuntimeEnv), count);
} else { // return only the tags|table name etc.
SExprInfo* pExprInfo = pOperator->pExpr; // todo use the column list instead of exprinfo
@@ -5760,7 +5761,7 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) {
pOperator->status = OP_EXEC_DONE;
}
- qDebug("QInfo:%"PRIu64" create tag values results completed, rows:%d", GET_QID(pRuntimeEnv), count);
+ qDebug("QInfo:0x%"PRIx64" create tag values results completed, rows:%d", GET_QID(pRuntimeEnv), count);
}
pRes->info.rows = count;
@@ -6557,13 +6558,13 @@ static int32_t doCreateFilterInfo(SColumnInfo* pCols, int32_t numOfCols, int32_t
int32_t lower = pSingleColFilter->filterInfo.lowerRelOptr;
int32_t upper = pSingleColFilter->filterInfo.upperRelOptr;
if (lower == TSDB_RELATION_INVALID && upper == TSDB_RELATION_INVALID) {
- qError("QInfo:%" PRIu64 " invalid filter info", qId);
+ qError("QInfo:0x%"PRIx64" invalid filter info", qId);
return TSDB_CODE_QRY_INVALID_MSG;
}
pSingleColFilter->fp = getFilterOperator(lower, upper);
if (pSingleColFilter->fp == NULL) {
- qError("QInfo:%" PRIu64 " invalid filter info", qId);
+ qError("QInfo:0x%"PRIx64" invalid filter info", qId);
return TSDB_CODE_QRY_INVALID_MSG;
}
@@ -6834,7 +6835,7 @@ SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SSqlGroupbyExpr* pGroupbyExpr
// todo refactor
pQInfo->query.queryBlockDist = (numOfOutput == 1 && pExprs[0].base.colInfo.colId == TSDB_BLOCK_DIST_COLUMN_INDEX);
- qDebug("qmsg:%p QInfo:%" PRIu64 "-%p created", pQueryMsg, pQInfo->qId, pQInfo);
+ qDebug("qmsg:%p QInfo:0x%" PRIx64 "-%p created", pQueryMsg, pQInfo->qId, pQInfo);
return pQInfo;
_cleanup_qinfo:
@@ -6910,7 +6911,7 @@ int32_t initQInfo(STsBufInfo* pTsBufInfo, void* tsdb, void* sourceOptr, SQInfo*
if ((QUERY_IS_ASC_QUERY(pQueryAttr) && (pQueryAttr->window.skey > pQueryAttr->window.ekey)) ||
(!QUERY_IS_ASC_QUERY(pQueryAttr) && (pQueryAttr->window.ekey > pQueryAttr->window.skey))) {
- qDebug("QInfo:%"PRIu64" no result in time range %" PRId64 "-%" PRId64 ", order %d", pQInfo->qId, pQueryAttr->window.skey,
+ qDebug("QInfo:0x%"PRIx64" no result in time range %" PRId64 "-%" PRId64 ", order %d", pQInfo->qId, pQueryAttr->window.skey,
pQueryAttr->window.ekey, pQueryAttr->order.order);
setQueryStatus(pRuntimeEnv, QUERY_COMPLETED);
pRuntimeEnv->tableqinfoGroupInfo.numOfTables = 0;
@@ -6919,7 +6920,7 @@ int32_t initQInfo(STsBufInfo* pTsBufInfo, void* tsdb, void* sourceOptr, SQInfo*
}
if (pRuntimeEnv->tableqinfoGroupInfo.numOfTables == 0) {
- qDebug("QInfo:%"PRIu64" no table qualified for tag filter, abort query", pQInfo->qId);
+ qDebug("QInfo:0x%"PRIx64" no table qualified for tag filter, abort query", pQInfo->qId);
setQueryStatus(pRuntimeEnv, QUERY_COMPLETED);
return TSDB_CODE_SUCCESS;
}
@@ -7005,7 +7006,7 @@ void freeQInfo(SQInfo *pQInfo) {
return;
}
- qDebug("QInfo:%"PRIu64" start to free QInfo", pQInfo->qId);
+ qDebug("QInfo:0x%"PRIx64" start to free QInfo", pQInfo->qId);
SQueryRuntimeEnv* pRuntimeEnv = &pQInfo->runtimeEnv;
releaseQueryBuf(pRuntimeEnv->tableqinfoGroupInfo.numOfTables);
@@ -7024,7 +7025,7 @@ void freeQInfo(SQInfo *pQInfo) {
taosArrayDestroy(pRuntimeEnv->groupResInfo.pRows);
pQInfo->signature = 0;
- qDebug("QInfo:%"PRIu64" QInfo is freed", pQInfo->qId);
+ qDebug("QInfo:0x%"PRIx64" QInfo is freed", pQInfo->qId);
tfree(pQInfo);
}
@@ -7044,7 +7045,7 @@ int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
off_t s = lseek(fileno(f), 0, SEEK_END);
assert(s == pRuntimeEnv->outputBuf->info.rows);
- qDebug("QInfo:%"PRIu64" ts comp data return, file:%p, size:%"PRId64, pQInfo->qId, f, (uint64_t)s);
+ qDebug("QInfo:0x%"PRIx64" ts comp data return, file:%p, size:%"PRId64, pQInfo->qId, f, (uint64_t)s);
if (fseek(f, 0, SEEK_SET) >= 0) {
size_t sz = fread(data, 1, s, f);
if(sz < s) { // todo handle error
@@ -7076,11 +7077,11 @@ int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
}
pRuntimeEnv->resultInfo.total += pRuntimeEnv->outputBuf->info.rows;
- qDebug("QInfo:%"PRIu64" current numOfRes rows:%d, total:%" PRId64, pQInfo->qId,
+ qDebug("QInfo:0x%"PRIx64" current numOfRes rows:%d, total:%" PRId64, pQInfo->qId,
pRuntimeEnv->outputBuf->info.rows, pRuntimeEnv->resultInfo.total);
if (pQueryAttr->limit.limit > 0 && pQueryAttr->limit.limit == pRuntimeEnv->resultInfo.total) {
- qDebug("QInfo:%"PRIu64" results limitation reached, limitation:%"PRId64, pQInfo->qId, pQueryAttr->limit.limit);
+ qDebug("QInfo:0x%"PRIx64" results limitation reached, limitation:%"PRId64, pQInfo->qId, pQueryAttr->limit.limit);
setQueryStatus(pRuntimeEnv, QUERY_OVER);
}
diff --git a/src/query/src/qExtbuffer.c b/src/query/src/qExtbuffer.c
index e6748edb05..1fe2819ea2 100644
--- a/src/query/src/qExtbuffer.c
+++ b/src/query/src/qExtbuffer.c
@@ -367,45 +367,14 @@ static int32_t tsCompareFunc(TSKEY k1, TSKEY k2, int32_t order) {
int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t bytes) {
switch (type) {
- case TSDB_DATA_TYPE_INT: {
- int32_t first = *(int32_t *) f1;
- int32_t second = *(int32_t *) f2;
- if (first == second) {
- return 0;
- }
- return (first < second) ? -1 : 1;
- };
- case TSDB_DATA_TYPE_DOUBLE: {
- DEFAULT_DOUBLE_COMP(GET_DOUBLE_VAL(f1), GET_DOUBLE_VAL(f2));
- };
- case TSDB_DATA_TYPE_FLOAT: {
- DEFAULT_FLOAT_COMP(GET_FLOAT_VAL(f1), GET_FLOAT_VAL(f2));
- };
- case TSDB_DATA_TYPE_BIGINT: {
- int64_t first = *(int64_t *)f1;
- int64_t second = *(int64_t *)f2;
- if (first == second) {
- return 0;
- }
- return (first < second) ? -1 : 1;
- };
- case TSDB_DATA_TYPE_SMALLINT: {
- int16_t first = *(int16_t *)f1;
- int16_t second = *(int16_t *)f2;
- if (first == second) {
- return 0;
- }
- return (first < second) ? -1 : 1;
- };
+ case TSDB_DATA_TYPE_INT: DEFAULT_COMP(GET_INT32_VAL(f1), GET_INT32_VAL(f2));
+ case TSDB_DATA_TYPE_DOUBLE: DEFAULT_DOUBLE_COMP(GET_DOUBLE_VAL(f1), GET_DOUBLE_VAL(f2));
+ case TSDB_DATA_TYPE_FLOAT: DEFAULT_FLOAT_COMP(GET_FLOAT_VAL(f1), GET_FLOAT_VAL(f2));
+ case TSDB_DATA_TYPE_BIGINT: DEFAULT_COMP(GET_INT64_VAL(f1), GET_INT64_VAL(f2));
+ case TSDB_DATA_TYPE_SMALLINT:DEFAULT_COMP(GET_INT16_VAL(f1), GET_INT16_VAL(f2));
case TSDB_DATA_TYPE_BOOL:
- case TSDB_DATA_TYPE_TINYINT: {
- int8_t first = *(int8_t *)f1;
- int8_t second = *(int8_t *)f2;
- if (first == second) {
- return 0;
- }
- return (first < second) ? -1 : 1;
- };
+ case TSDB_DATA_TYPE_TINYINT: DEFAULT_COMP(GET_INT8_VAL(f1), GET_INT8_VAL(f2));
+
case TSDB_DATA_TYPE_BINARY: {
int32_t len1 = varDataLen(f1);
int32_t len2 = varDataLen(f2);
@@ -428,6 +397,10 @@ int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t
}
return (ret < 0) ? -1 : 1;
};
+ case TSDB_DATA_TYPE_UTINYINT: DEFAULT_COMP(GET_UINT8_VAL(f1), GET_UINT8_VAL(f2));
+ case TSDB_DATA_TYPE_USMALLINT: DEFAULT_COMP(GET_UINT16_VAL(f1), GET_UINT16_VAL(f2));
+ case TSDB_DATA_TYPE_UINT: DEFAULT_COMP(GET_UINT32_VAL(f1), GET_UINT32_VAL(f2));
+ case TSDB_DATA_TYPE_UBIGINT: DEFAULT_COMP(GET_UINT64_VAL(f1), GET_UINT64_VAL(f2));
}
return 0;
diff --git a/src/query/src/qResultbuf.c b/src/query/src/qResultbuf.c
index f83caf2d8f..05ecf2e9b1 100644
--- a/src/query/src/qResultbuf.c
+++ b/src/query/src/qResultbuf.c
@@ -43,7 +43,7 @@ int32_t createDiskbasedResultBuffer(SDiskbasedResultBuf** pResultBuf, int32_t pa
pResBuf->emptyDummyIdList = taosArrayInit(1, sizeof(int32_t));
- qDebug("QInfo:%"PRIu64" create resBuf for output, page size:%d, inmem buf pages:%d, file:%s", qId, pResBuf->pageSize,
+ qDebug("QInfo:0x%"PRIx64" create resBuf for output, page size:%d, inmem buf pages:%d, file:%s", qId, pResBuf->pageSize,
pResBuf->inMemPages, pResBuf->path);
return TSDB_CODE_SUCCESS;
@@ -410,13 +410,13 @@ void destroyResultBuf(SDiskbasedResultBuf* pResultBuf) {
}
if (pResultBuf->file != NULL) {
- qDebug("QInfo:%"PRIu64" res output buffer closed, total:%.2f Kb, inmem size:%.2f Kb, file size:%.2f Kb",
+ qDebug("QInfo:0x%"PRIx64" res output buffer closed, total:%.2f Kb, inmem size:%.2f Kb, file size:%.2f Kb",
pResultBuf->qId, pResultBuf->totalBufSize/1024.0, listNEles(pResultBuf->lruList) * pResultBuf->pageSize / 1024.0,
pResultBuf->fileSize/1024.0);
fclose(pResultBuf->file);
} else {
- qDebug("QInfo:%"PRIu64" res output buffer closed, total:%.2f Kb, no file created", pResultBuf->qId,
+ qDebug("QInfo:0x%"PRIx64" res output buffer closed, total:%.2f Kb, no file created", pResultBuf->qId,
pResultBuf->totalBufSize/1024.0);
}
diff --git a/src/query/src/qSqlParser.c b/src/query/src/qSqlParser.c
index 0cb832f358..fb8f164ed3 100644
--- a/src/query/src/qSqlParser.c
+++ b/src/query/src/qSqlParser.c
@@ -144,12 +144,15 @@ tSqlExpr *tSqlExprCreateIdValue(SStrToken *pToken, int32_t optrType) {
pSqlExpr->value.nType = TSDB_DATA_TYPE_BIGINT;
pSqlExpr->tokenId = TK_TIMESTAMP; // TK_TIMESTAMP used to denote the time value is in microsecond
pSqlExpr->type = SQL_NODE_VALUE;
+ pSqlExpr->flags |= 1 << EXPR_FLAG_US_TIMESTAMP;
} else if (optrType == TK_VARIABLE) {
int32_t ret = parseAbsoluteDuration(pToken->z, pToken->n, &pSqlExpr->value.i64);
if (ret != TSDB_CODE_SUCCESS) {
terrno = TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
}
+ pSqlExpr->flags |= 1 << EXPR_FLAG_US_TIMESTAMP;
+ pSqlExpr->flags |= 1 << EXPR_FLAG_TIMESTAMP_VAR;
pSqlExpr->value.nType = TSDB_DATA_TYPE_BIGINT;
pSqlExpr->tokenId = TK_TIMESTAMP;
pSqlExpr->type = SQL_NODE_VALUE;
@@ -217,6 +220,15 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) {
pExpr->value.nType = TSDB_DATA_TYPE_BIGINT;
pExpr->tokenId = pLeft->tokenId;
pExpr->type = SQL_NODE_VALUE;
+ pExpr->flags = pLeft->flags | pRight->flags;
+
+ if ((pLeft->flags & (1 << EXPR_FLAG_TIMESTAMP_VAR)) && (pRight->flags & (1 << EXPR_FLAG_TIMESTAMP_VAR))) {
+ pExpr->flags |= 1 << EXPR_FLAG_TS_ERROR;
+ } else {
+ pExpr->flags &= ~(1 << EXPR_FLAG_TIMESTAMP_VAR);
+ pExpr->flags &= ~(1 << EXPR_FLAG_TS_ERROR);
+ }
+
switch (optrType) {
case TK_PLUS: {
@@ -245,7 +257,6 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) {
tSqlExprDestroy(pLeft);
tSqlExprDestroy(pRight);
-
} else if ((pLeft->tokenId == TK_FLOAT && pRight->tokenId == TK_INTEGER) ||
(pLeft->tokenId == TK_INTEGER && pRight->tokenId == TK_FLOAT) ||
(pLeft->tokenId == TK_FLOAT && pRight->tokenId == TK_FLOAT)) {
diff --git a/src/query/src/queryMain.c b/src/query/src/queryMain.c
index 3ac05499a9..3e4401cf93 100644
--- a/src/query/src/queryMain.c
+++ b/src/query/src/queryMain.c
@@ -206,7 +206,7 @@ bool qTableQuery(qinfo_t qinfo, uint64_t *qId) {
int64_t curOwner = 0;
if ((curOwner = atomic_val_compare_exchange_64(&pQInfo->owner, 0, threadId)) != 0) {
- qError("QInfo:%"PRIu64"-%p qhandle is now executed by thread:%p", pQInfo->qId, pQInfo, (void*) curOwner);
+ qError("QInfo:0x%"PRIx64"-%p qhandle is now executed by thread:%p", pQInfo->qId, pQInfo, (void*) curOwner);
pQInfo->code = TSDB_CODE_QRY_IN_EXEC;
return false;
}
@@ -215,13 +215,13 @@ bool qTableQuery(qinfo_t qinfo, uint64_t *qId) {
pQInfo->startExecTs = taosGetTimestampSec();
if (isQueryKilled(pQInfo)) {
- qDebug("QInfo:%"PRIu64" it is already killed, abort", pQInfo->qId);
+ qDebug("QInfo:0x%"PRIx64" it is already killed, abort", pQInfo->qId);
return doBuildResCheck(pQInfo);
}
SQueryRuntimeEnv* pRuntimeEnv = &pQInfo->runtimeEnv;
if (pRuntimeEnv->tableqinfoGroupInfo.numOfTables == 0) {
- qDebug("QInfo:%"PRIu64" no table exists for query, abort", pQInfo->qId);
+ qDebug("QInfo:0x%"PRIx64" no table exists for query, abort", pQInfo->qId);
setQueryStatus(pRuntimeEnv, QUERY_COMPLETED);
return doBuildResCheck(pQInfo);
}
@@ -230,22 +230,22 @@ bool qTableQuery(qinfo_t qinfo, uint64_t *qId) {
int32_t ret = setjmp(pQInfo->runtimeEnv.env);
if (ret != TSDB_CODE_SUCCESS) {
pQInfo->code = ret;
- qDebug("QInfo:%"PRIu64" query abort due to error/cancel occurs, code:%s", pQInfo->qId, tstrerror(pQInfo->code));
+ qDebug("QInfo:0x%"PRIx64" query abort due to error/cancel occurs, code:%s", pQInfo->qId, tstrerror(pQInfo->code));
return doBuildResCheck(pQInfo);
}
- qDebug("QInfo:%"PRIu64" query task is launched", pQInfo->qId);
+ qDebug("QInfo:0x%"PRIx64" query task is launched", pQInfo->qId);
bool newgroup = false;
pRuntimeEnv->outputBuf = pRuntimeEnv->proot->exec(pRuntimeEnv->proot, &newgroup);
if (isQueryKilled(pQInfo)) {
- qDebug("QInfo:%"PRIu64" query is killed", pQInfo->qId);
+ qDebug("QInfo:0x%"PRIx64" query is killed", pQInfo->qId);
} else if (GET_NUM_OF_RESULTS(pRuntimeEnv) == 0) {
- qDebug("QInfo:%"PRIu64" over, %u tables queried, %"PRId64" rows are returned", pQInfo->qId, pRuntimeEnv->tableqinfoGroupInfo.numOfTables,
+ qDebug("QInfo:0x%"PRIx64" over, %u tables queried, %"PRId64" rows are returned", pQInfo->qId, pRuntimeEnv->tableqinfoGroupInfo.numOfTables,
pRuntimeEnv->resultInfo.total);
} else {
- qDebug("QInfo:%"PRIu64" query paused, %d rows returned, numOfTotal:%" PRId64 " rows",
+ qDebug("QInfo:0x%"PRIx64" query paused, %d rows returned, numOfTotal:%" PRId64 " rows",
pQInfo->qId, GET_NUM_OF_RESULTS(pRuntimeEnv), pRuntimeEnv->resultInfo.total + GET_NUM_OF_RESULTS(pRuntimeEnv));
}
@@ -256,13 +256,13 @@ int32_t qRetrieveQueryResultInfo(qinfo_t qinfo, bool* buildRes, void* pRspContex
SQInfo *pQInfo = (SQInfo *)qinfo;
if (pQInfo == NULL || !isValidQInfo(pQInfo)) {
- qError("QInfo:%"PRIu64" invalid qhandle", pQInfo->qId);
+ qError("QInfo:0x%"PRIx64" invalid qhandle", pQInfo->qId);
return TSDB_CODE_QRY_INVALID_QHANDLE;
}
*buildRes = false;
if (IS_QUERY_KILLED(pQInfo)) {
- qDebug("QInfo:%"PRIu64" query is killed, code:0x%08x", pQInfo->qId, pQInfo->code);
+ qDebug("QInfo:0x%"PRIx64" query is killed, code:0x%08x", pQInfo->qId, pQInfo->code);
return pQInfo->code;
}
@@ -282,11 +282,11 @@ int32_t qRetrieveQueryResultInfo(qinfo_t qinfo, bool* buildRes, void* pRspContex
assert(pQInfo->rspContext == NULL);
if (pQInfo->dataReady == QUERY_RESULT_READY) {
*buildRes = true;
- qDebug("QInfo:%"PRIu64" retrieve result info, rowsize:%d, rows:%d, code:%s", pQInfo->qId, pQueryAttr->resultRowSize,
+ qDebug("QInfo:0x%"PRIx64" retrieve result info, rowsize:%d, rows:%d, code:%s", pQInfo->qId, pQuery->resultRowSize,
GET_NUM_OF_RESULTS(pRuntimeEnv), tstrerror(pQInfo->code));
} else {
*buildRes = false;
- qDebug("QInfo:%"PRIu64" retrieve req set query return result after paused", pQInfo->qId);
+ qDebug("QInfo:0x%"PRIx64" retrieve req set query return result after paused", pQInfo->qId);
pQInfo->rspContext = pRspContext;
assert(pQInfo->rspContext != NULL);
}
@@ -345,10 +345,10 @@ int32_t qDumpRetrieveResult(qinfo_t qinfo, SRetrieveTableRsp **pRsp, int32_t *co
// here current thread hold the refcount, so it is safe to free tsdbQueryHandle.
*continueExec = false;
(*pRsp)->completed = 1; // notify no more result to client
- qDebug("QInfo:%"PRIu64" no more results to retrieve", pQInfo->qId);
+ qDebug("QInfo:0x%"PRIx64" no more results to retrieve", pQInfo->qId);
} else {
*continueExec = true;
- qDebug("QInfo:%"PRIu64" has more results to retrieve", pQInfo->qId);
+ qDebug("QInfo:0x%"PRIx64" has more results to retrieve", pQInfo->qId);
}
// the memory should be freed if the code of pQInfo is not TSDB_CODE_SUCCESS
@@ -374,7 +374,7 @@ int32_t qKillQuery(qinfo_t qinfo) {
return TSDB_CODE_QRY_INVALID_QHANDLE;
}
- qDebug("QInfo:%"PRIu64" query killed", pQInfo->qId);
+ qDebug("QInfo:0x%"PRIx64" query killed", pQInfo->qId);
setQueryKilled(pQInfo);
// Wait for the query executing thread being stopped/
@@ -402,7 +402,7 @@ void qDestroyQueryInfo(qinfo_t qHandle) {
return;
}
- qDebug("QInfo:%"PRIu64" query completed", pQInfo->qId);
+ qDebug("QInfo:0x%"PRIx64" query completed", pQInfo->qId);
queryCostStatis(pQInfo); // print the query cost summary
freeQInfo(pQInfo);
}
@@ -485,7 +485,7 @@ void** qRegisterQInfo(void* pMgmt, uint64_t qId, void *qInfo) {
SQueryMgmt *pQueryMgmt = pMgmt;
if (pQueryMgmt->qinfoPool == NULL) {
- qError("QInfo:%"PRIu64"-%p failed to add qhandle into qMgmt, since qMgmt is closed", qId, (void*)qInfo);
+ qError("QInfo:0x%"PRIx64"-%p failed to add qhandle into qMgmt, since qMgmt is closed", qId, (void*)qInfo);
terrno = TSDB_CODE_VND_INVALID_VGROUP_ID;
return NULL;
}
@@ -493,7 +493,7 @@ void** qRegisterQInfo(void* pMgmt, uint64_t qId, void *qInfo) {
pthread_mutex_lock(&pQueryMgmt->lock);
if (pQueryMgmt->closed) {
pthread_mutex_unlock(&pQueryMgmt->lock);
- qError("QInfo:%"PRIu64"-%p failed to add qhandle into cache, since qMgmt is colsing", qId, (void*)qInfo);
+ qError("QInfo:0x%"PRIx64"-%p failed to add qhandle into cache, since qMgmt is colsing", qId, (void*)qInfo);
terrno = TSDB_CODE_VND_INVALID_VGROUP_ID;
return NULL;
} else {
diff --git a/src/query/src/sql.c b/src/query/src/sql.c
index a283a8b916..f3929da022 100644
--- a/src/query/src/sql.c
+++ b/src/query/src/sql.c
@@ -128,16 +128,16 @@ typedef union {
#define ParseARG_STORE yypParser->pInfo = pInfo
#define YYFALLBACK 1
#define YYNSTATE 315
-#define YYNRULE 267
+#define YYNRULE 269
#define YYNTOKEN 187
#define YY_MAX_SHIFT 314
-#define YY_MIN_SHIFTREDUCE 506
-#define YY_MAX_SHIFTREDUCE 772
-#define YY_ERROR_ACTION 773
-#define YY_ACCEPT_ACTION 774
-#define YY_NO_ACTION 775
-#define YY_MIN_REDUCE 776
-#define YY_MAX_REDUCE 1042
+#define YY_MIN_SHIFTREDUCE 508
+#define YY_MAX_SHIFTREDUCE 776
+#define YY_ERROR_ACTION 777
+#define YY_ACCEPT_ACTION 778
+#define YY_NO_ACTION 779
+#define YY_MIN_REDUCE 780
+#define YY_MAX_REDUCE 1048
/************* End control #defines *******************************************/
/* Define the yytestcase() macro to be a no-op if is not already defined
@@ -203,76 +203,77 @@ typedef union {
** yy_default[] Default action for each state.
**
*********** Begin parsing tables **********************************************/
-#define YY_ACTTAB_COUNT (680)
+#define YY_ACTTAB_COUNT (683)
static const YYACTIONTYPE yy_action[] = {
- /* 0 */ 133, 553, 202, 312, 206, 140, 943, 226, 140, 554,
- /* 10 */ 774, 314, 17, 47, 48, 140, 51, 52, 30, 181,
- /* 20 */ 214, 41, 181, 50, 262, 55, 53, 57, 54, 1023,
- /* 30 */ 922, 209, 1024, 46, 45, 179, 181, 44, 43, 42,
- /* 40 */ 47, 48, 920, 51, 52, 208, 1024, 214, 41, 553,
- /* 50 */ 50, 262, 55, 53, 57, 54, 934, 554, 185, 203,
- /* 60 */ 46, 45, 919, 247, 44, 43, 42, 48, 940, 51,
- /* 70 */ 52, 242, 974, 214, 41, 79, 50, 262, 55, 53,
- /* 80 */ 57, 54, 975, 632, 257, 30, 46, 45, 278, 225,
- /* 90 */ 44, 43, 42, 507, 508, 509, 510, 511, 512, 513,
- /* 100 */ 514, 515, 516, 517, 518, 519, 313, 553, 85, 231,
- /* 110 */ 70, 288, 287, 47, 48, 554, 51, 52, 298, 219,
- /* 120 */ 214, 41, 553, 50, 262, 55, 53, 57, 54, 918,
- /* 130 */ 554, 105, 718, 46, 45, 1020, 298, 44, 43, 42,
- /* 140 */ 47, 49, 910, 51, 52, 922, 140, 214, 41, 234,
- /* 150 */ 50, 262, 55, 53, 57, 54, 1019, 238, 237, 227,
+ /* 0 */ 133, 555, 204, 312, 208, 140, 947, 226, 140, 556,
+ /* 10 */ 778, 314, 17, 47, 48, 140, 51, 52, 30, 181,
+ /* 20 */ 214, 41, 181, 50, 262, 55, 53, 57, 54, 1029,
+ /* 30 */ 926, 211, 1030, 46, 45, 179, 181, 44, 43, 42,
+ /* 40 */ 47, 48, 924, 51, 52, 210, 1030, 214, 41, 555,
+ /* 50 */ 50, 262, 55, 53, 57, 54, 938, 556, 185, 205,
+ /* 60 */ 46, 45, 923, 247, 44, 43, 42, 48, 944, 51,
+ /* 70 */ 52, 242, 978, 214, 41, 79, 50, 262, 55, 53,
+ /* 80 */ 57, 54, 979, 634, 257, 30, 46, 45, 278, 225,
+ /* 90 */ 44, 43, 42, 509, 510, 511, 512, 513, 514, 515,
+ /* 100 */ 516, 517, 518, 519, 520, 521, 313, 555, 85, 231,
+ /* 110 */ 70, 288, 287, 47, 48, 556, 51, 52, 298, 219,
+ /* 120 */ 214, 41, 555, 50, 262, 55, 53, 57, 54, 922,
+ /* 130 */ 556, 105, 720, 46, 45, 1026, 298, 44, 43, 42,
+ /* 140 */ 47, 49, 914, 51, 52, 926, 140, 214, 41, 234,
+ /* 150 */ 50, 262, 55, 53, 57, 54, 1025, 238, 237, 227,
/* 160 */ 46, 45, 285, 284, 44, 43, 42, 23, 276, 307,
/* 170 */ 306, 275, 274, 273, 305, 272, 304, 303, 302, 271,
- /* 180 */ 301, 300, 882, 30, 870, 871, 872, 873, 874, 875,
- /* 190 */ 876, 877, 878, 879, 880, 881, 883, 884, 51, 52,
- /* 200 */ 821, 1018, 214, 41, 166, 50, 262, 55, 53, 57,
- /* 210 */ 54, 259, 18, 78, 82, 46, 45, 198, 223, 44,
- /* 220 */ 43, 42, 213, 731, 217, 25, 722, 919, 725, 190,
- /* 230 */ 728, 221, 213, 731, 199, 191, 722, 724, 725, 727,
- /* 240 */ 728, 118, 117, 189, 263, 905, 906, 29, 909, 44,
- /* 250 */ 43, 42, 30, 74, 210, 211, 308, 922, 261, 30,
- /* 260 */ 23, 36, 307, 306, 210, 211, 934, 305, 30, 304,
- /* 270 */ 303, 302, 74, 301, 300, 890, 908, 183, 888, 889,
- /* 280 */ 36, 204, 922, 891, 916, 893, 894, 892, 224, 895,
- /* 290 */ 896, 280, 656, 218, 830, 653, 919, 654, 166, 655,
- /* 300 */ 281, 69, 241, 919, 68, 55, 53, 57, 54, 282,
- /* 310 */ 197, 671, 919, 46, 45, 30, 822, 44, 43, 42,
- /* 320 */ 166, 103, 108, 228, 229, 56, 220, 97, 107, 113,
- /* 330 */ 116, 106, 732, 907, 723, 56, 726, 110, 730, 30,
- /* 340 */ 735, 12, 732, 5, 156, 84, 184, 81, 730, 33,
- /* 350 */ 155, 92, 87, 91, 729, 278, 286, 1, 154, 919,
- /* 360 */ 174, 170, 186, 212, 729, 80, 172, 169, 121, 120,
- /* 370 */ 119, 46, 45, 3, 167, 44, 43, 42, 71, 720,
- /* 380 */ 290, 699, 700, 919, 311, 310, 126, 243, 668, 675,
- /* 390 */ 678, 31, 684, 690, 180, 24, 135, 60, 245, 691,
- /* 400 */ 752, 657, 733, 20, 19, 61, 19, 6, 64, 642,
- /* 410 */ 265, 1034, 644, 31, 31, 721, 60, 267, 643, 187,
- /* 420 */ 28, 83, 60, 268, 96, 95, 188, 62, 65, 14,
- /* 430 */ 13, 102, 101, 660, 67, 661, 631, 194, 16, 15,
- /* 440 */ 658, 195, 659, 115, 114, 131, 129, 193, 178, 192,
- /* 450 */ 182, 921, 985, 984, 215, 981, 239, 980, 132, 942,
- /* 460 */ 216, 289, 39, 950, 952, 967, 134, 966, 138, 935,
- /* 470 */ 246, 130, 248, 917, 151, 915, 150, 205, 683, 250,
- /* 480 */ 152, 886, 299, 153, 291, 148, 146, 260, 142, 932,
- /* 490 */ 141, 58, 833, 270, 66, 255, 143, 37, 63, 176,
- /* 500 */ 34, 279, 829, 258, 144, 1039, 93, 256, 1038, 1036,
- /* 510 */ 157, 254, 283, 1033, 99, 1032, 1030, 158, 851, 35,
- /* 520 */ 252, 145, 32, 38, 177, 818, 109, 816, 111, 40,
- /* 530 */ 112, 814, 813, 230, 168, 811, 810, 809, 808, 807,
- /* 540 */ 806, 171, 173, 803, 801, 799, 797, 795, 175, 249,
- /* 550 */ 244, 72, 75, 104, 251, 968, 292, 293, 294, 295,
- /* 560 */ 296, 297, 309, 200, 222, 269, 772, 232, 201, 233,
- /* 570 */ 771, 88, 89, 196, 235, 236, 770, 758, 757, 240,
- /* 580 */ 245, 8, 264, 73, 812, 663, 805, 161, 852, 159,
- /* 590 */ 160, 163, 162, 164, 165, 122, 123, 124, 804, 76,
- /* 600 */ 125, 796, 4, 2, 685, 136, 137, 688, 77, 149,
- /* 610 */ 147, 207, 253, 86, 692, 898, 139, 9, 10, 26,
- /* 620 */ 27, 734, 7, 11, 736, 21, 22, 266, 595, 591,
- /* 630 */ 589, 84, 588, 587, 584, 557, 277, 94, 90, 31,
- /* 640 */ 634, 633, 59, 630, 579, 577, 98, 569, 575, 571,
- /* 650 */ 573, 567, 565, 100, 598, 597, 596, 594, 593, 592,
- /* 660 */ 590, 586, 585, 60, 555, 523, 521, 776, 775, 127,
- /* 670 */ 775, 775, 775, 775, 775, 775, 775, 775, 775, 128,
+ /* 180 */ 301, 300, 886, 30, 874, 875, 876, 877, 878, 879,
+ /* 190 */ 880, 881, 882, 883, 884, 885, 887, 888, 51, 52,
+ /* 200 */ 825, 1024, 214, 41, 166, 50, 262, 55, 53, 57,
+ /* 210 */ 54, 259, 18, 78, 82, 46, 45, 61, 223, 44,
+ /* 220 */ 43, 42, 213, 735, 217, 25, 724, 923, 727, 190,
+ /* 230 */ 730, 221, 213, 735, 198, 191, 724, 912, 727, 62,
+ /* 240 */ 730, 118, 117, 189, 69, 909, 910, 29, 913, 44,
+ /* 250 */ 43, 42, 30, 74, 200, 201, 308, 926, 261, 30,
+ /* 260 */ 23, 36, 307, 306, 200, 201, 938, 305, 30, 304,
+ /* 270 */ 303, 302, 74, 301, 300, 894, 911, 199, 892, 893,
+ /* 280 */ 36, 206, 926, 895, 920, 897, 898, 896, 224, 899,
+ /* 290 */ 900, 280, 658, 218, 834, 655, 923, 656, 166, 657,
+ /* 300 */ 281, 673, 241, 923, 68, 55, 53, 57, 54, 282,
+ /* 310 */ 197, 263, 923, 46, 45, 30, 278, 44, 43, 42,
+ /* 320 */ 80, 103, 108, 228, 229, 56, 220, 97, 107, 113,
+ /* 330 */ 116, 106, 736, 71, 726, 56, 729, 110, 732, 30,
+ /* 340 */ 1, 154, 736, 5, 156, 725, 183, 728, 732, 33,
+ /* 350 */ 155, 92, 87, 91, 731, 680, 286, 184, 826, 923,
+ /* 360 */ 174, 170, 166, 245, 731, 212, 172, 169, 121, 120,
+ /* 370 */ 119, 46, 45, 3, 167, 44, 43, 42, 12, 677,
+ /* 380 */ 290, 722, 84, 923, 81, 670, 311, 310, 126, 701,
+ /* 390 */ 702, 243, 24, 686, 692, 31, 693, 135, 60, 756,
+ /* 400 */ 20, 659, 737, 19, 64, 186, 19, 739, 644, 6,
+ /* 410 */ 180, 265, 31, 187, 646, 31, 267, 723, 60, 645,
+ /* 420 */ 83, 188, 28, 60, 65, 268, 662, 67, 663, 633,
+ /* 430 */ 96, 95, 660, 194, 661, 115, 114, 14, 13, 102,
+ /* 440 */ 101, 195, 16, 15, 131, 129, 733, 193, 178, 192,
+ /* 450 */ 182, 1040, 925, 989, 988, 215, 985, 734, 239, 984,
+ /* 460 */ 216, 289, 132, 946, 39, 971, 954, 970, 956, 939,
+ /* 470 */ 246, 130, 248, 134, 138, 921, 150, 244, 151, 207,
+ /* 480 */ 250, 299, 685, 149, 919, 255, 142, 936, 143, 141,
+ /* 490 */ 144, 152, 256, 153, 260, 258, 66, 145, 837, 270,
+ /* 500 */ 63, 37, 58, 176, 34, 254, 279, 833, 1045, 252,
+ /* 510 */ 93, 1044, 1042, 249, 147, 157, 283, 1039, 99, 1038,
+ /* 520 */ 146, 1036, 158, 855, 35, 32, 38, 177, 822, 40,
+ /* 530 */ 109, 104, 820, 111, 112, 818, 817, 230, 168, 815,
+ /* 540 */ 814, 813, 812, 811, 810, 171, 173, 807, 805, 803,
+ /* 550 */ 291, 801, 799, 175, 292, 72, 75, 293, 251, 972,
+ /* 560 */ 294, 295, 296, 297, 309, 776, 202, 232, 222, 269,
+ /* 570 */ 233, 775, 236, 235, 774, 761, 203, 762, 88, 196,
+ /* 580 */ 89, 240, 245, 264, 8, 73, 76, 665, 687, 690,
+ /* 590 */ 816, 161, 136, 122, 856, 159, 164, 160, 162, 163,
+ /* 600 */ 165, 123, 809, 2, 890, 124, 808, 4, 125, 800,
+ /* 610 */ 137, 209, 77, 148, 253, 26, 694, 139, 9, 902,
+ /* 620 */ 10, 27, 738, 7, 11, 740, 21, 22, 266, 86,
+ /* 630 */ 597, 593, 84, 591, 590, 589, 586, 559, 277, 90,
+ /* 640 */ 31, 94, 98, 59, 100, 636, 635, 632, 581, 579,
+ /* 650 */ 571, 577, 573, 575, 569, 567, 600, 599, 598, 596,
+ /* 660 */ 595, 594, 592, 588, 587, 60, 557, 525, 523, 780,
+ /* 670 */ 779, 779, 779, 779, 779, 779, 779, 779, 779, 779,
+ /* 680 */ 779, 127, 128,
};
static const YYCODETYPE yy_lookahead[] = {
/* 0 */ 191, 1, 190, 191, 210, 191, 191, 191, 191, 9,
@@ -296,54 +297,54 @@ static const YYCODETYPE yy_lookahead[] = {
/* 180 */ 101, 102, 209, 191, 211, 212, 213, 214, 215, 216,
/* 190 */ 217, 218, 219, 220, 221, 222, 223, 224, 16, 17,
/* 200 */ 196, 252, 20, 21, 200, 23, 24, 25, 26, 27,
- /* 210 */ 28, 256, 44, 258, 197, 33, 34, 252, 67, 37,
+ /* 210 */ 28, 256, 44, 258, 197, 33, 34, 109, 67, 37,
/* 220 */ 38, 39, 1, 2, 232, 104, 5, 235, 7, 61,
- /* 230 */ 9, 210, 1, 2, 252, 67, 5, 5, 7, 7,
- /* 240 */ 9, 73, 74, 75, 15, 228, 229, 230, 231, 37,
+ /* 230 */ 9, 210, 1, 2, 252, 67, 5, 0, 7, 131,
+ /* 240 */ 9, 73, 74, 75, 197, 228, 229, 230, 231, 37,
/* 250 */ 38, 39, 191, 104, 33, 34, 210, 236, 37, 191,
/* 260 */ 88, 112, 90, 91, 33, 34, 234, 95, 191, 97,
- /* 270 */ 98, 99, 104, 101, 102, 209, 0, 252, 212, 213,
+ /* 270 */ 98, 99, 104, 101, 102, 209, 229, 252, 212, 213,
/* 280 */ 112, 249, 236, 217, 191, 219, 220, 221, 137, 223,
/* 290 */ 224, 140, 2, 232, 196, 5, 235, 7, 200, 9,
- /* 300 */ 232, 197, 134, 235, 136, 25, 26, 27, 28, 232,
- /* 310 */ 142, 37, 235, 33, 34, 191, 196, 37, 38, 39,
- /* 320 */ 200, 62, 63, 33, 34, 104, 233, 68, 69, 70,
- /* 330 */ 71, 72, 111, 229, 5, 104, 7, 78, 117, 191,
- /* 340 */ 111, 104, 111, 62, 63, 108, 252, 110, 117, 68,
- /* 350 */ 69, 70, 71, 72, 133, 79, 232, 198, 199, 235,
- /* 360 */ 62, 63, 252, 60, 133, 237, 68, 69, 70, 71,
- /* 370 */ 72, 33, 34, 194, 195, 37, 38, 39, 250, 1,
- /* 380 */ 232, 124, 125, 235, 64, 65, 66, 105, 109, 115,
- /* 390 */ 105, 109, 105, 105, 252, 116, 109, 109, 113, 105,
- /* 400 */ 105, 111, 105, 109, 109, 109, 109, 104, 109, 105,
- /* 410 */ 105, 236, 105, 109, 109, 37, 109, 105, 105, 252,
- /* 420 */ 104, 109, 109, 107, 138, 139, 252, 131, 129, 138,
- /* 430 */ 139, 138, 139, 5, 104, 7, 106, 252, 138, 139,
- /* 440 */ 5, 252, 7, 76, 77, 62, 63, 252, 252, 252,
- /* 450 */ 252, 236, 227, 227, 227, 227, 191, 227, 191, 191,
- /* 460 */ 227, 227, 251, 191, 191, 259, 191, 259, 191, 234,
- /* 470 */ 234, 60, 255, 234, 191, 191, 238, 255, 117, 255,
- /* 480 */ 191, 225, 103, 191, 86, 240, 242, 122, 246, 248,
- /* 490 */ 247, 127, 191, 191, 128, 255, 245, 191, 130, 191,
- /* 500 */ 191, 191, 191, 126, 244, 191, 191, 121, 191, 191,
- /* 510 */ 191, 120, 191, 191, 191, 191, 191, 191, 191, 191,
- /* 520 */ 119, 243, 191, 191, 191, 191, 191, 191, 191, 132,
- /* 530 */ 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
- /* 540 */ 191, 191, 191, 191, 191, 191, 191, 191, 191, 118,
- /* 550 */ 192, 192, 192, 87, 192, 192, 50, 83, 85, 54,
- /* 560 */ 84, 82, 79, 192, 192, 192, 5, 145, 192, 5,
- /* 570 */ 5, 197, 197, 192, 145, 5, 5, 90, 89, 135,
- /* 580 */ 113, 104, 107, 114, 192, 105, 192, 202, 208, 207,
- /* 590 */ 206, 203, 205, 204, 201, 193, 193, 193, 192, 109,
- /* 600 */ 193, 192, 194, 198, 105, 104, 109, 105, 104, 239,
- /* 610 */ 241, 1, 104, 76, 105, 225, 104, 123, 123, 109,
- /* 620 */ 109, 105, 104, 104, 111, 104, 104, 107, 9, 5,
- /* 630 */ 5, 108, 5, 5, 5, 80, 15, 139, 76, 109,
- /* 640 */ 5, 5, 16, 105, 5, 5, 139, 5, 5, 5,
- /* 650 */ 5, 5, 5, 139, 5, 5, 5, 5, 5, 5,
- /* 660 */ 5, 5, 5, 109, 80, 60, 59, 0, 263, 21,
- /* 670 */ 263, 263, 263, 263, 263, 263, 263, 263, 263, 21,
- /* 680 */ 263, 263, 263, 263, 263, 263, 263, 263, 263, 263,
+ /* 300 */ 232, 37, 134, 235, 136, 25, 26, 27, 28, 232,
+ /* 310 */ 142, 15, 235, 33, 34, 191, 79, 37, 38, 39,
+ /* 320 */ 237, 62, 63, 33, 34, 104, 233, 68, 69, 70,
+ /* 330 */ 71, 72, 111, 250, 5, 104, 7, 78, 117, 191,
+ /* 340 */ 198, 199, 111, 62, 63, 5, 252, 7, 117, 68,
+ /* 350 */ 69, 70, 71, 72, 133, 105, 232, 252, 196, 235,
+ /* 360 */ 62, 63, 200, 113, 133, 60, 68, 69, 70, 71,
+ /* 370 */ 72, 33, 34, 194, 195, 37, 38, 39, 104, 115,
+ /* 380 */ 232, 1, 108, 235, 110, 109, 64, 65, 66, 124,
+ /* 390 */ 125, 105, 116, 105, 105, 109, 105, 109, 109, 105,
+ /* 400 */ 109, 111, 105, 109, 109, 252, 109, 111, 105, 104,
+ /* 410 */ 252, 105, 109, 252, 105, 109, 105, 37, 109, 105,
+ /* 420 */ 109, 252, 104, 109, 129, 107, 5, 104, 7, 106,
+ /* 430 */ 138, 139, 5, 252, 7, 76, 77, 138, 139, 138,
+ /* 440 */ 139, 252, 138, 139, 62, 63, 117, 252, 252, 252,
+ /* 450 */ 252, 236, 236, 227, 227, 227, 227, 117, 191, 227,
+ /* 460 */ 227, 227, 191, 191, 251, 259, 191, 259, 191, 234,
+ /* 470 */ 234, 60, 255, 191, 191, 234, 238, 192, 191, 255,
+ /* 480 */ 255, 103, 117, 239, 191, 255, 246, 248, 245, 247,
+ /* 490 */ 244, 191, 121, 191, 122, 126, 128, 243, 191, 191,
+ /* 500 */ 130, 191, 127, 191, 191, 120, 191, 191, 191, 119,
+ /* 510 */ 191, 191, 191, 118, 241, 191, 191, 191, 191, 191,
+ /* 520 */ 242, 191, 191, 191, 191, 191, 191, 191, 191, 132,
+ /* 530 */ 191, 87, 191, 191, 191, 191, 191, 191, 191, 191,
+ /* 540 */ 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
+ /* 550 */ 86, 191, 191, 191, 50, 192, 192, 83, 192, 192,
+ /* 560 */ 85, 54, 84, 82, 79, 5, 192, 145, 192, 192,
+ /* 570 */ 5, 5, 5, 145, 5, 89, 192, 90, 197, 192,
+ /* 580 */ 197, 135, 113, 107, 104, 114, 109, 105, 105, 105,
+ /* 590 */ 192, 202, 104, 193, 208, 207, 204, 206, 205, 203,
+ /* 600 */ 201, 193, 192, 198, 225, 193, 192, 194, 193, 192,
+ /* 610 */ 109, 1, 104, 240, 104, 109, 105, 104, 123, 225,
+ /* 620 */ 123, 109, 105, 104, 104, 111, 104, 104, 107, 76,
+ /* 630 */ 9, 5, 108, 5, 5, 5, 5, 80, 15, 76,
+ /* 640 */ 109, 139, 139, 16, 139, 5, 5, 105, 5, 5,
+ /* 650 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ /* 660 */ 5, 5, 5, 5, 5, 109, 80, 60, 59, 0,
+ /* 670 */ 263, 263, 263, 263, 263, 263, 263, 263, 263, 263,
+ /* 680 */ 263, 21, 21, 263, 263, 263, 263, 263, 263, 263,
/* 690 */ 263, 263, 263, 263, 263, 263, 263, 263, 263, 263,
/* 700 */ 263, 263, 263, 263, 263, 263, 263, 263, 263, 263,
/* 710 */ 263, 263, 263, 263, 263, 263, 263, 263, 263, 263,
@@ -361,101 +362,101 @@ static const YYCODETYPE yy_lookahead[] = {
/* 830 */ 263, 263, 263, 263, 263, 263, 263, 263, 263, 263,
/* 840 */ 263, 263, 263, 263, 263, 263, 263, 263, 263, 263,
/* 850 */ 263, 263, 263, 263, 263, 263, 263, 263, 263, 263,
- /* 860 */ 263, 263, 263, 263, 263, 263, 263,
+ /* 860 */ 263, 263, 263, 263, 263, 263, 263, 263, 263, 263,
};
#define YY_SHIFT_COUNT (314)
#define YY_SHIFT_MIN (0)
-#define YY_SHIFT_MAX (667)
+#define YY_SHIFT_MAX (669)
static const unsigned short int yy_shift_ofst[] = {
/* 0 */ 168, 79, 79, 172, 172, 9, 221, 231, 106, 106,
/* 10 */ 106, 106, 106, 106, 106, 106, 106, 0, 48, 231,
- /* 20 */ 290, 290, 290, 290, 121, 149, 106, 106, 106, 276,
- /* 30 */ 106, 106, 55, 9, 37, 37, 680, 680, 680, 231,
+ /* 20 */ 290, 290, 290, 290, 121, 149, 106, 106, 106, 237,
+ /* 30 */ 106, 106, 55, 9, 37, 37, 683, 683, 683, 231,
/* 40 */ 231, 231, 231, 231, 231, 231, 231, 231, 231, 231,
/* 50 */ 231, 231, 231, 231, 231, 231, 231, 231, 231, 290,
/* 60 */ 290, 78, 78, 78, 78, 78, 78, 78, 106, 106,
- /* 70 */ 106, 274, 106, 149, 149, 106, 106, 106, 257, 257,
- /* 80 */ 279, 149, 106, 106, 106, 106, 106, 106, 106, 106,
+ /* 70 */ 106, 264, 106, 149, 149, 106, 106, 106, 265, 265,
+ /* 80 */ 276, 149, 106, 106, 106, 106, 106, 106, 106, 106,
/* 90 */ 106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
/* 100 */ 106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
/* 110 */ 106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
/* 120 */ 106, 106, 106, 106, 106, 106, 106, 106, 106, 106,
- /* 130 */ 106, 106, 411, 411, 411, 361, 361, 361, 411, 361,
- /* 140 */ 411, 366, 368, 364, 365, 377, 386, 391, 401, 431,
- /* 150 */ 397, 411, 411, 411, 379, 9, 9, 411, 411, 466,
- /* 160 */ 398, 506, 474, 473, 505, 476, 479, 379, 411, 483,
- /* 170 */ 483, 411, 483, 411, 483, 411, 680, 680, 27, 100,
+ /* 130 */ 106, 106, 411, 411, 411, 365, 365, 365, 411, 365,
+ /* 140 */ 411, 368, 370, 375, 372, 369, 371, 385, 390, 395,
+ /* 150 */ 397, 411, 411, 411, 378, 9, 9, 411, 411, 444,
+ /* 160 */ 464, 504, 474, 475, 507, 478, 481, 378, 411, 485,
+ /* 170 */ 485, 411, 485, 411, 485, 411, 683, 683, 27, 100,
/* 180 */ 127, 100, 100, 53, 182, 280, 280, 280, 280, 259,
/* 190 */ 281, 298, 338, 338, 338, 338, 22, 14, 212, 212,
- /* 200 */ 237, 151, 320, 282, 285, 287, 288, 294, 295, 297,
- /* 210 */ 232, 329, 378, 303, 229, 296, 299, 304, 305, 307,
- /* 220 */ 312, 313, 316, 286, 291, 293, 330, 300, 428, 435,
- /* 230 */ 367, 383, 561, 422, 564, 565, 429, 570, 571, 487,
- /* 240 */ 489, 444, 467, 475, 477, 469, 480, 490, 499, 501,
- /* 250 */ 502, 497, 504, 610, 508, 509, 512, 510, 494, 511,
- /* 260 */ 495, 516, 518, 513, 519, 475, 521, 520, 522, 523,
- /* 270 */ 537, 619, 624, 625, 627, 628, 629, 555, 621, 562,
- /* 280 */ 498, 530, 530, 626, 507, 514, 530, 635, 636, 538,
- /* 290 */ 530, 639, 640, 642, 643, 644, 645, 646, 647, 649,
- /* 300 */ 650, 651, 652, 653, 654, 655, 656, 657, 554, 584,
- /* 310 */ 648, 658, 605, 607, 667,
+ /* 200 */ 329, 340, 274, 151, 322, 286, 250, 288, 289, 291,
+ /* 210 */ 294, 297, 380, 305, 296, 108, 295, 303, 306, 309,
+ /* 220 */ 311, 314, 318, 292, 299, 301, 323, 304, 421, 427,
+ /* 230 */ 359, 382, 560, 422, 565, 566, 428, 567, 569, 487,
+ /* 240 */ 486, 446, 469, 476, 480, 471, 482, 477, 483, 488,
+ /* 250 */ 484, 501, 508, 610, 510, 511, 513, 506, 495, 512,
+ /* 260 */ 497, 517, 519, 514, 520, 476, 522, 521, 523, 524,
+ /* 270 */ 553, 621, 626, 628, 629, 630, 631, 557, 623, 563,
+ /* 280 */ 502, 531, 531, 627, 503, 505, 531, 640, 641, 542,
+ /* 290 */ 531, 643, 644, 645, 646, 647, 648, 649, 650, 651,
+ /* 300 */ 652, 653, 654, 655, 656, 657, 658, 659, 556, 586,
+ /* 310 */ 660, 661, 607, 609, 669,
};
#define YY_REDUCE_COUNT (177)
#define YY_REDUCE_MIN (-240)
-#define YY_REDUCE_MAX (409)
+#define YY_REDUCE_MAX (417)
static const short yy_reduce_ofst[] = {
/* 0 */ -178, -27, -27, 66, 66, 17, -230, -216, -173, -176,
/* 10 */ -45, -8, 61, 68, 77, 124, 148, -185, -188, -233,
/* 20 */ -206, -91, 21, 46, -191, 32, -186, -183, 93, -89,
- /* 30 */ -184, -106, 4, 104, 98, 120, 128, 159, 179, -240,
- /* 40 */ -217, -194, -117, -96, -51, -35, -18, 25, 94, 110,
- /* 50 */ 142, 167, 174, 185, 189, 195, 196, 197, 198, 175,
- /* 60 */ 215, 225, 226, 227, 228, 230, 233, 234, 265, 267,
- /* 70 */ 268, 211, 272, 235, 236, 273, 275, 277, 206, 208,
- /* 80 */ 238, 239, 283, 284, 289, 292, 301, 302, 306, 308,
- /* 90 */ 309, 310, 311, 314, 315, 317, 318, 319, 321, 322,
- /* 100 */ 323, 324, 325, 326, 327, 328, 331, 332, 333, 334,
- /* 110 */ 335, 336, 337, 339, 340, 341, 342, 343, 344, 345,
- /* 120 */ 346, 347, 348, 349, 350, 351, 352, 353, 354, 355,
- /* 130 */ 356, 357, 358, 359, 360, 217, 222, 224, 362, 240,
- /* 140 */ 363, 241, 243, 242, 251, 260, 278, 244, 369, 245,
- /* 150 */ 370, 371, 372, 373, 256, 374, 375, 376, 381, 380,
- /* 160 */ 382, 384, 385, 387, 388, 389, 393, 390, 392, 402,
- /* 170 */ 403, 394, 404, 406, 407, 409, 405, 408,
+ /* 30 */ -184, -106, 4, 47, 98, 162, 83, 142, 179, -240,
+ /* 40 */ -217, -194, -117, -96, -51, -18, 25, 94, 105, 153,
+ /* 50 */ 158, 161, 169, 181, 189, 195, 196, 197, 198, 215,
+ /* 60 */ 216, 226, 227, 228, 229, 232, 233, 234, 267, 271,
+ /* 70 */ 272, 213, 275, 235, 236, 277, 282, 283, 206, 208,
+ /* 80 */ 238, 241, 287, 293, 300, 302, 307, 308, 310, 312,
+ /* 90 */ 313, 315, 316, 317, 319, 320, 321, 324, 325, 326,
+ /* 100 */ 327, 328, 330, 331, 332, 333, 334, 335, 336, 337,
+ /* 110 */ 339, 341, 342, 343, 344, 345, 346, 347, 348, 349,
+ /* 120 */ 350, 351, 352, 353, 354, 355, 356, 357, 358, 360,
+ /* 130 */ 361, 362, 285, 363, 364, 217, 224, 225, 366, 230,
+ /* 140 */ 367, 239, 242, 240, 243, 246, 254, 278, 273, 373,
+ /* 150 */ 244, 374, 376, 377, 379, 381, 383, 384, 387, 386,
+ /* 160 */ 388, 391, 389, 393, 396, 392, 399, 394, 398, 400,
+ /* 170 */ 408, 410, 412, 414, 415, 417, 405, 413,
};
static const YYACTIONTYPE yy_default[] = {
- /* 0 */ 773, 885, 831, 897, 819, 828, 1026, 1026, 773, 773,
- /* 10 */ 773, 773, 773, 773, 773, 773, 773, 944, 792, 1026,
- /* 20 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 828,
- /* 30 */ 773, 773, 834, 828, 834, 834, 939, 869, 887, 773,
- /* 40 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773,
- /* 50 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773,
- /* 60 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773,
- /* 70 */ 773, 946, 949, 773, 773, 951, 773, 773, 971, 971,
- /* 80 */ 937, 773, 773, 773, 773, 773, 773, 773, 773, 773,
- /* 90 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773,
- /* 100 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 817,
- /* 110 */ 773, 815, 773, 773, 773, 773, 773, 773, 773, 773,
- /* 120 */ 773, 773, 773, 773, 773, 773, 802, 773, 773, 773,
- /* 130 */ 773, 773, 794, 794, 794, 773, 773, 773, 794, 773,
- /* 140 */ 794, 978, 982, 976, 964, 972, 963, 959, 957, 956,
- /* 150 */ 986, 794, 794, 794, 832, 828, 828, 794, 794, 850,
- /* 160 */ 848, 846, 838, 844, 840, 842, 836, 820, 794, 826,
- /* 170 */ 826, 794, 826, 794, 826, 794, 869, 887, 773, 987,
- /* 180 */ 773, 1025, 977, 1015, 1014, 1021, 1013, 1012, 1011, 773,
- /* 190 */ 773, 773, 1007, 1008, 1010, 1009, 773, 773, 1017, 1016,
- /* 200 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773,
- /* 210 */ 773, 773, 773, 989, 773, 983, 979, 773, 773, 773,
- /* 220 */ 773, 773, 773, 773, 773, 773, 899, 773, 773, 773,
- /* 230 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773,
- /* 240 */ 773, 773, 936, 773, 773, 773, 773, 947, 773, 773,
- /* 250 */ 773, 773, 773, 773, 773, 773, 773, 973, 773, 965,
- /* 260 */ 773, 773, 773, 773, 773, 911, 773, 773, 773, 773,
- /* 270 */ 773, 773, 773, 773, 773, 773, 773, 773, 773, 773,
- /* 280 */ 773, 1037, 1035, 773, 773, 773, 1031, 773, 773, 773,
- /* 290 */ 1029, 773, 773, 773, 773, 773, 773, 773, 773, 773,
- /* 300 */ 773, 773, 773, 773, 773, 773, 773, 773, 853, 773,
- /* 310 */ 800, 798, 773, 790, 773,
+ /* 0 */ 777, 889, 835, 901, 823, 832, 1032, 1032, 777, 777,
+ /* 10 */ 777, 777, 777, 777, 777, 777, 777, 948, 796, 1032,
+ /* 20 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 832,
+ /* 30 */ 777, 777, 838, 832, 838, 838, 943, 873, 891, 777,
+ /* 40 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777,
+ /* 50 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777,
+ /* 60 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777,
+ /* 70 */ 777, 950, 953, 777, 777, 955, 777, 777, 975, 975,
+ /* 80 */ 941, 777, 777, 777, 777, 777, 777, 777, 777, 777,
+ /* 90 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777,
+ /* 100 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 821,
+ /* 110 */ 777, 819, 777, 777, 777, 777, 777, 777, 777, 777,
+ /* 120 */ 777, 777, 777, 777, 777, 777, 806, 777, 777, 777,
+ /* 130 */ 777, 777, 798, 798, 798, 777, 777, 777, 798, 777,
+ /* 140 */ 798, 982, 986, 980, 968, 976, 967, 963, 961, 960,
+ /* 150 */ 990, 798, 798, 798, 836, 832, 832, 798, 798, 854,
+ /* 160 */ 852, 850, 842, 848, 844, 846, 840, 824, 798, 830,
+ /* 170 */ 830, 798, 830, 798, 830, 798, 873, 891, 777, 991,
+ /* 180 */ 777, 1031, 981, 1021, 1020, 1027, 1019, 1018, 1017, 777,
+ /* 190 */ 777, 777, 1013, 1014, 1016, 1015, 777, 777, 1023, 1022,
+ /* 200 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777,
+ /* 210 */ 777, 777, 777, 993, 777, 987, 983, 777, 777, 777,
+ /* 220 */ 777, 777, 777, 777, 777, 777, 903, 777, 777, 777,
+ /* 230 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777,
+ /* 240 */ 777, 777, 940, 777, 777, 777, 777, 951, 777, 777,
+ /* 250 */ 777, 777, 777, 777, 777, 777, 777, 977, 777, 969,
+ /* 260 */ 777, 777, 777, 777, 777, 915, 777, 777, 777, 777,
+ /* 270 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777,
+ /* 280 */ 777, 1043, 1041, 777, 777, 777, 1037, 777, 777, 777,
+ /* 290 */ 1035, 777, 777, 777, 777, 777, 777, 777, 777, 777,
+ /* 300 */ 777, 777, 777, 777, 777, 777, 777, 777, 857, 777,
+ /* 310 */ 804, 802, 777, 794, 777,
};
/********** End of lemon-generated parsing tables *****************************/
@@ -1243,48 +1244,50 @@ static const char *const yyRuleName[] = {
/* 222 */ "expr ::= STRING",
/* 223 */ "expr ::= NOW",
/* 224 */ "expr ::= VARIABLE",
- /* 225 */ "expr ::= BOOL",
- /* 226 */ "expr ::= NULL",
- /* 227 */ "expr ::= ID LP exprlist RP",
- /* 228 */ "expr ::= ID LP STAR RP",
- /* 229 */ "expr ::= expr IS NULL",
- /* 230 */ "expr ::= expr IS NOT NULL",
- /* 231 */ "expr ::= expr LT expr",
- /* 232 */ "expr ::= expr GT expr",
- /* 233 */ "expr ::= expr LE expr",
- /* 234 */ "expr ::= expr GE expr",
- /* 235 */ "expr ::= expr NE expr",
- /* 236 */ "expr ::= expr EQ expr",
- /* 237 */ "expr ::= expr BETWEEN expr AND expr",
- /* 238 */ "expr ::= expr AND expr",
- /* 239 */ "expr ::= expr OR expr",
- /* 240 */ "expr ::= expr PLUS expr",
- /* 241 */ "expr ::= expr MINUS expr",
- /* 242 */ "expr ::= expr STAR expr",
- /* 243 */ "expr ::= expr SLASH expr",
- /* 244 */ "expr ::= expr REM expr",
- /* 245 */ "expr ::= expr LIKE expr",
- /* 246 */ "expr ::= expr IN LP exprlist RP",
- /* 247 */ "exprlist ::= exprlist COMMA expritem",
- /* 248 */ "exprlist ::= expritem",
- /* 249 */ "expritem ::= expr",
- /* 250 */ "expritem ::=",
- /* 251 */ "cmd ::= RESET QUERY CACHE",
- /* 252 */ "cmd ::= SYNCDB ids REPLICA",
- /* 253 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist",
- /* 254 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids",
- /* 255 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist",
- /* 256 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids",
- /* 257 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids",
- /* 258 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem",
- /* 259 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist",
- /* 260 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids",
- /* 261 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist",
- /* 262 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids",
- /* 263 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids",
- /* 264 */ "cmd ::= KILL CONNECTION INTEGER",
- /* 265 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER",
- /* 266 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER",
+ /* 225 */ "expr ::= PLUS VARIABLE",
+ /* 226 */ "expr ::= MINUS VARIABLE",
+ /* 227 */ "expr ::= BOOL",
+ /* 228 */ "expr ::= NULL",
+ /* 229 */ "expr ::= ID LP exprlist RP",
+ /* 230 */ "expr ::= ID LP STAR RP",
+ /* 231 */ "expr ::= expr IS NULL",
+ /* 232 */ "expr ::= expr IS NOT NULL",
+ /* 233 */ "expr ::= expr LT expr",
+ /* 234 */ "expr ::= expr GT expr",
+ /* 235 */ "expr ::= expr LE expr",
+ /* 236 */ "expr ::= expr GE expr",
+ /* 237 */ "expr ::= expr NE expr",
+ /* 238 */ "expr ::= expr EQ expr",
+ /* 239 */ "expr ::= expr BETWEEN expr AND expr",
+ /* 240 */ "expr ::= expr AND expr",
+ /* 241 */ "expr ::= expr OR expr",
+ /* 242 */ "expr ::= expr PLUS expr",
+ /* 243 */ "expr ::= expr MINUS expr",
+ /* 244 */ "expr ::= expr STAR expr",
+ /* 245 */ "expr ::= expr SLASH expr",
+ /* 246 */ "expr ::= expr REM expr",
+ /* 247 */ "expr ::= expr LIKE expr",
+ /* 248 */ "expr ::= expr IN LP exprlist RP",
+ /* 249 */ "exprlist ::= exprlist COMMA expritem",
+ /* 250 */ "exprlist ::= expritem",
+ /* 251 */ "expritem ::= expr",
+ /* 252 */ "expritem ::=",
+ /* 253 */ "cmd ::= RESET QUERY CACHE",
+ /* 254 */ "cmd ::= SYNCDB ids REPLICA",
+ /* 255 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist",
+ /* 256 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids",
+ /* 257 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist",
+ /* 258 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids",
+ /* 259 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids",
+ /* 260 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem",
+ /* 261 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist",
+ /* 262 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids",
+ /* 263 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist",
+ /* 264 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids",
+ /* 265 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids",
+ /* 266 */ "cmd ::= KILL CONNECTION INTEGER",
+ /* 267 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER",
+ /* 268 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER",
};
#endif /* NDEBUG */
@@ -1975,48 +1978,50 @@ static const struct {
{ 252, -1 }, /* (222) expr ::= STRING */
{ 252, -1 }, /* (223) expr ::= NOW */
{ 252, -1 }, /* (224) expr ::= VARIABLE */
- { 252, -1 }, /* (225) expr ::= BOOL */
- { 252, -1 }, /* (226) expr ::= NULL */
- { 252, -4 }, /* (227) expr ::= ID LP exprlist RP */
- { 252, -4 }, /* (228) expr ::= ID LP STAR RP */
- { 252, -3 }, /* (229) expr ::= expr IS NULL */
- { 252, -4 }, /* (230) expr ::= expr IS NOT NULL */
- { 252, -3 }, /* (231) expr ::= expr LT expr */
- { 252, -3 }, /* (232) expr ::= expr GT expr */
- { 252, -3 }, /* (233) expr ::= expr LE expr */
- { 252, -3 }, /* (234) expr ::= expr GE expr */
- { 252, -3 }, /* (235) expr ::= expr NE expr */
- { 252, -3 }, /* (236) expr ::= expr EQ expr */
- { 252, -5 }, /* (237) expr ::= expr BETWEEN expr AND expr */
- { 252, -3 }, /* (238) expr ::= expr AND expr */
- { 252, -3 }, /* (239) expr ::= expr OR expr */
- { 252, -3 }, /* (240) expr ::= expr PLUS expr */
- { 252, -3 }, /* (241) expr ::= expr MINUS expr */
- { 252, -3 }, /* (242) expr ::= expr STAR expr */
- { 252, -3 }, /* (243) expr ::= expr SLASH expr */
- { 252, -3 }, /* (244) expr ::= expr REM expr */
- { 252, -3 }, /* (245) expr ::= expr LIKE expr */
- { 252, -5 }, /* (246) expr ::= expr IN LP exprlist RP */
- { 261, -3 }, /* (247) exprlist ::= exprlist COMMA expritem */
- { 261, -1 }, /* (248) exprlist ::= expritem */
- { 262, -1 }, /* (249) expritem ::= expr */
- { 262, 0 }, /* (250) expritem ::= */
- { 189, -3 }, /* (251) cmd ::= RESET QUERY CACHE */
- { 189, -3 }, /* (252) cmd ::= SYNCDB ids REPLICA */
- { 189, -7 }, /* (253) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
- { 189, -7 }, /* (254) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
- { 189, -7 }, /* (255) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
- { 189, -7 }, /* (256) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
- { 189, -8 }, /* (257) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
- { 189, -9 }, /* (258) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
- { 189, -7 }, /* (259) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */
- { 189, -7 }, /* (260) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */
- { 189, -7 }, /* (261) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */
- { 189, -7 }, /* (262) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */
- { 189, -8 }, /* (263) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */
- { 189, -3 }, /* (264) cmd ::= KILL CONNECTION INTEGER */
- { 189, -5 }, /* (265) cmd ::= KILL STREAM INTEGER COLON INTEGER */
- { 189, -5 }, /* (266) cmd ::= KILL QUERY INTEGER COLON INTEGER */
+ { 252, -2 }, /* (225) expr ::= PLUS VARIABLE */
+ { 252, -2 }, /* (226) expr ::= MINUS VARIABLE */
+ { 252, -1 }, /* (227) expr ::= BOOL */
+ { 252, -1 }, /* (228) expr ::= NULL */
+ { 252, -4 }, /* (229) expr ::= ID LP exprlist RP */
+ { 252, -4 }, /* (230) expr ::= ID LP STAR RP */
+ { 252, -3 }, /* (231) expr ::= expr IS NULL */
+ { 252, -4 }, /* (232) expr ::= expr IS NOT NULL */
+ { 252, -3 }, /* (233) expr ::= expr LT expr */
+ { 252, -3 }, /* (234) expr ::= expr GT expr */
+ { 252, -3 }, /* (235) expr ::= expr LE expr */
+ { 252, -3 }, /* (236) expr ::= expr GE expr */
+ { 252, -3 }, /* (237) expr ::= expr NE expr */
+ { 252, -3 }, /* (238) expr ::= expr EQ expr */
+ { 252, -5 }, /* (239) expr ::= expr BETWEEN expr AND expr */
+ { 252, -3 }, /* (240) expr ::= expr AND expr */
+ { 252, -3 }, /* (241) expr ::= expr OR expr */
+ { 252, -3 }, /* (242) expr ::= expr PLUS expr */
+ { 252, -3 }, /* (243) expr ::= expr MINUS expr */
+ { 252, -3 }, /* (244) expr ::= expr STAR expr */
+ { 252, -3 }, /* (245) expr ::= expr SLASH expr */
+ { 252, -3 }, /* (246) expr ::= expr REM expr */
+ { 252, -3 }, /* (247) expr ::= expr LIKE expr */
+ { 252, -5 }, /* (248) expr ::= expr IN LP exprlist RP */
+ { 261, -3 }, /* (249) exprlist ::= exprlist COMMA expritem */
+ { 261, -1 }, /* (250) exprlist ::= expritem */
+ { 262, -1 }, /* (251) expritem ::= expr */
+ { 262, 0 }, /* (252) expritem ::= */
+ { 189, -3 }, /* (253) cmd ::= RESET QUERY CACHE */
+ { 189, -3 }, /* (254) cmd ::= SYNCDB ids REPLICA */
+ { 189, -7 }, /* (255) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
+ { 189, -7 }, /* (256) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
+ { 189, -7 }, /* (257) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
+ { 189, -7 }, /* (258) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
+ { 189, -8 }, /* (259) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
+ { 189, -9 }, /* (260) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
+ { 189, -7 }, /* (261) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */
+ { 189, -7 }, /* (262) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */
+ { 189, -7 }, /* (263) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */
+ { 189, -7 }, /* (264) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */
+ { 189, -8 }, /* (265) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */
+ { 189, -3 }, /* (266) cmd ::= KILL CONNECTION INTEGER */
+ { 189, -5 }, /* (267) cmd ::= KILL STREAM INTEGER COLON INTEGER */
+ { 189, -5 }, /* (268) cmd ::= KILL QUERY INTEGER COLON INTEGER */
};
static void yy_accept(yyParser*); /* Forward Declaration */
@@ -2794,7 +2799,7 @@ static void yy_reduce(
break;
case 200: /* having_opt ::= */
case 210: /* where_opt ::= */ yytestcase(yyruleno==210);
- case 250: /* expritem ::= */ yytestcase(yyruleno==250);
+ case 252: /* expritem ::= */ yytestcase(yyruleno==252);
{yymsp[1].minor.yy118 = 0;}
break;
case 201: /* having_opt ::= HAVING expr */
@@ -2867,120 +2872,125 @@ static void yy_reduce(
{ yylhsminor.yy118 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);}
yymsp[0].minor.yy118 = yylhsminor.yy118;
break;
- case 225: /* expr ::= BOOL */
+ case 225: /* expr ::= PLUS VARIABLE */
+ case 226: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==226);
+{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy118 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);}
+ yymsp[-1].minor.yy118 = yylhsminor.yy118;
+ break;
+ case 227: /* expr ::= BOOL */
{ yylhsminor.yy118 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);}
yymsp[0].minor.yy118 = yylhsminor.yy118;
break;
- case 226: /* expr ::= NULL */
+ case 228: /* expr ::= NULL */
{ yylhsminor.yy118 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);}
yymsp[0].minor.yy118 = yylhsminor.yy118;
break;
- case 227: /* expr ::= ID LP exprlist RP */
+ case 229: /* expr ::= ID LP exprlist RP */
{ yylhsminor.yy118 = tSqlExprCreateFunction(yymsp[-1].minor.yy159, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); }
yymsp[-3].minor.yy118 = yylhsminor.yy118;
break;
- case 228: /* expr ::= ID LP STAR RP */
+ case 230: /* expr ::= ID LP STAR RP */
{ yylhsminor.yy118 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); }
yymsp[-3].minor.yy118 = yylhsminor.yy118;
break;
- case 229: /* expr ::= expr IS NULL */
+ case 231: /* expr ::= expr IS NULL */
{yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, NULL, TK_ISNULL);}
yymsp[-2].minor.yy118 = yylhsminor.yy118;
break;
- case 230: /* expr ::= expr IS NOT NULL */
+ case 232: /* expr ::= expr IS NOT NULL */
{yylhsminor.yy118 = tSqlExprCreate(yymsp[-3].minor.yy118, NULL, TK_NOTNULL);}
yymsp[-3].minor.yy118 = yylhsminor.yy118;
break;
- case 231: /* expr ::= expr LT expr */
+ case 233: /* expr ::= expr LT expr */
{yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_LT);}
yymsp[-2].minor.yy118 = yylhsminor.yy118;
break;
- case 232: /* expr ::= expr GT expr */
+ case 234: /* expr ::= expr GT expr */
{yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_GT);}
yymsp[-2].minor.yy118 = yylhsminor.yy118;
break;
- case 233: /* expr ::= expr LE expr */
+ case 235: /* expr ::= expr LE expr */
{yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_LE);}
yymsp[-2].minor.yy118 = yylhsminor.yy118;
break;
- case 234: /* expr ::= expr GE expr */
+ case 236: /* expr ::= expr GE expr */
{yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_GE);}
yymsp[-2].minor.yy118 = yylhsminor.yy118;
break;
- case 235: /* expr ::= expr NE expr */
+ case 237: /* expr ::= expr NE expr */
{yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_NE);}
yymsp[-2].minor.yy118 = yylhsminor.yy118;
break;
- case 236: /* expr ::= expr EQ expr */
+ case 238: /* expr ::= expr EQ expr */
{yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_EQ);}
yymsp[-2].minor.yy118 = yylhsminor.yy118;
break;
- case 237: /* expr ::= expr BETWEEN expr AND expr */
+ case 239: /* expr ::= expr BETWEEN expr AND expr */
{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy118); yylhsminor.yy118 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy118, yymsp[-2].minor.yy118, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy118, TK_LE), TK_AND);}
yymsp[-4].minor.yy118 = yylhsminor.yy118;
break;
- case 238: /* expr ::= expr AND expr */
+ case 240: /* expr ::= expr AND expr */
{yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_AND);}
yymsp[-2].minor.yy118 = yylhsminor.yy118;
break;
- case 239: /* expr ::= expr OR expr */
+ case 241: /* expr ::= expr OR expr */
{yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_OR); }
yymsp[-2].minor.yy118 = yylhsminor.yy118;
break;
- case 240: /* expr ::= expr PLUS expr */
+ case 242: /* expr ::= expr PLUS expr */
{yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_PLUS); }
yymsp[-2].minor.yy118 = yylhsminor.yy118;
break;
- case 241: /* expr ::= expr MINUS expr */
+ case 243: /* expr ::= expr MINUS expr */
{yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_MINUS); }
yymsp[-2].minor.yy118 = yylhsminor.yy118;
break;
- case 242: /* expr ::= expr STAR expr */
+ case 244: /* expr ::= expr STAR expr */
{yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_STAR); }
yymsp[-2].minor.yy118 = yylhsminor.yy118;
break;
- case 243: /* expr ::= expr SLASH expr */
+ case 245: /* expr ::= expr SLASH expr */
{yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_DIVIDE);}
yymsp[-2].minor.yy118 = yylhsminor.yy118;
break;
- case 244: /* expr ::= expr REM expr */
+ case 246: /* expr ::= expr REM expr */
{yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_REM); }
yymsp[-2].minor.yy118 = yylhsminor.yy118;
break;
- case 245: /* expr ::= expr LIKE expr */
+ case 247: /* expr ::= expr LIKE expr */
{yylhsminor.yy118 = tSqlExprCreate(yymsp[-2].minor.yy118, yymsp[0].minor.yy118, TK_LIKE); }
yymsp[-2].minor.yy118 = yylhsminor.yy118;
break;
- case 246: /* expr ::= expr IN LP exprlist RP */
+ case 248: /* expr ::= expr IN LP exprlist RP */
{yylhsminor.yy118 = tSqlExprCreate(yymsp[-4].minor.yy118, (tSqlExpr*)yymsp[-1].minor.yy159, TK_IN); }
yymsp[-4].minor.yy118 = yylhsminor.yy118;
break;
- case 247: /* exprlist ::= exprlist COMMA expritem */
+ case 249: /* exprlist ::= exprlist COMMA expritem */
{yylhsminor.yy159 = tSqlExprListAppend(yymsp[-2].minor.yy159,yymsp[0].minor.yy118,0, 0);}
yymsp[-2].minor.yy159 = yylhsminor.yy159;
break;
- case 248: /* exprlist ::= expritem */
+ case 250: /* exprlist ::= expritem */
{yylhsminor.yy159 = tSqlExprListAppend(0,yymsp[0].minor.yy118,0, 0);}
yymsp[0].minor.yy159 = yylhsminor.yy159;
break;
- case 249: /* expritem ::= expr */
+ case 251: /* expritem ::= expr */
{yylhsminor.yy118 = yymsp[0].minor.yy118;}
yymsp[0].minor.yy118 = yylhsminor.yy118;
break;
- case 251: /* cmd ::= RESET QUERY CACHE */
+ case 253: /* cmd ::= RESET QUERY CACHE */
{ setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);}
break;
- case 252: /* cmd ::= SYNCDB ids REPLICA */
+ case 254: /* cmd ::= SYNCDB ids REPLICA */
{ setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &yymsp[-1].minor.yy0);}
break;
- case 253: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
+ case 255: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy159, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 254: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
+ case 256: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
@@ -2991,14 +3001,14 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 255: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
+ case 257: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy159, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 256: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
+ case 258: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
@@ -3009,7 +3019,7 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 257: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
+ case 259: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */
{
yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n;
@@ -3023,7 +3033,7 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 258: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
+ case 260: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */
{
yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n;
@@ -3035,14 +3045,14 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 259: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */
+ case 261: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy159, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 260: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */
+ case 262: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
@@ -3053,14 +3063,14 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 261: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */
+ case 263: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy159, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE);
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 262: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */
+ case 264: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */
{
yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n;
@@ -3071,7 +3081,7 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 263: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */
+ case 265: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */
{
yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n;
@@ -3085,13 +3095,13 @@ static void yy_reduce(
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
}
break;
- case 264: /* cmd ::= KILL CONNECTION INTEGER */
+ case 266: /* cmd ::= KILL CONNECTION INTEGER */
{setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);}
break;
- case 265: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */
+ case 267: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */
{yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_STREAM, &yymsp[-2].minor.yy0);}
break;
- case 266: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */
+ case 268: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */
{yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_QUERY, &yymsp[-2].minor.yy0);}
break;
default:
diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c
index 9b37435a01..9df25409de 100644
--- a/src/tsdb/src/tsdbRead.c
+++ b/src/tsdb/src/tsdbRead.c
@@ -286,7 +286,7 @@ static SArray* createCheckInfoFromTableGroup(STsdbQueryHandle* pQueryHandle, STa
}
taosArrayPush(pTableCheckInfo, &info);
- tsdbDebug("%p check table uid:%"PRId64", tid:%d from lastKey:%"PRId64" %"PRIu64, pQueryHandle, info.tableId.uid,
+ tsdbDebug("%p check table uid:%"PRId64", tid:%d from lastKey:%"PRId64" 0x%"PRIx64, pQueryHandle, info.tableId.uid,
info.tableId.tid, info.lastKey, pQueryHandle->qId);
}
}
@@ -440,7 +440,7 @@ TsdbQueryHandleT* tsdbQueryTables(STsdbRepo* tsdb, STsdbQueryCond* pCond, STable
tsdbMayTakeMemSnapshot(pQueryHandle, psTable);
- tsdbDebug("%p total numOfTable:%" PRIzu " in query, %"PRIu64, pQueryHandle, taosArrayGetSize(pQueryHandle->pTableCheckInfo), pQueryHandle->qId);
+ tsdbDebug("%p total numOfTable:%" PRIzu " in query, 0x%"PRIx64, pQueryHandle, taosArrayGetSize(pQueryHandle->pTableCheckInfo), pQueryHandle->qId);
return (TsdbQueryHandleT) pQueryHandle;
}
@@ -651,7 +651,7 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh
SDataRow row = (SDataRow)SL_GET_NODE_DATA(node);
TSKEY key = dataRowKey(row); // first timestamp in buffer
tsdbDebug("%p uid:%" PRId64 ", tid:%d check data in mem from skey:%" PRId64 ", order:%d, ts range in buf:%" PRId64
- "-%" PRId64 ", lastKey:%" PRId64 ", numOfRows:%"PRId64", %"PRIu64,
+ "-%" PRId64 ", lastKey:%" PRId64 ", numOfRows:%"PRId64", 0x%"PRIx64,
pHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, key, order, pMem->keyFirst, pMem->keyLast,
pCheckInfo->lastKey, pMem->numOfRows, pHandle->qId);
@@ -662,7 +662,7 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh
}
} else {
- tsdbDebug("%p uid:%"PRId64", tid:%d no data in mem, %"PRIu64, pHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid,
+ tsdbDebug("%p uid:%"PRId64", tid:%d no data in mem, 0x%"PRIx64, pHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid,
pHandle->qId);
}
@@ -673,7 +673,7 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh
SDataRow row = (SDataRow)SL_GET_NODE_DATA(node);
TSKEY key = dataRowKey(row); // first timestamp in buffer
tsdbDebug("%p uid:%" PRId64 ", tid:%d check data in imem from skey:%" PRId64 ", order:%d, ts range in buf:%" PRId64
- "-%" PRId64 ", lastKey:%" PRId64 ", numOfRows:%"PRId64", %"PRIu64,
+ "-%" PRId64 ", lastKey:%" PRId64 ", numOfRows:%"PRId64", 0x%"PRIx64,
pHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, key, order, pIMem->keyFirst, pIMem->keyLast,
pCheckInfo->lastKey, pIMem->numOfRows, pHandle->qId);
@@ -683,7 +683,7 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh
assert(pCheckInfo->lastKey >= key);
}
} else {
- tsdbDebug("%p uid:%"PRId64", tid:%d no data in imem, %"PRIu64, pHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid,
+ tsdbDebug("%p uid:%"PRId64", tid:%d no data in imem, 0x%"PRIx64, pHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid,
pHandle->qId);
}
@@ -811,7 +811,7 @@ static bool hasMoreDataInCache(STsdbQueryHandle* pHandle) {
}
pCheckInfo->lastKey = dataRowKey(row); // first timestamp in buffer
- tsdbDebug("%p uid:%" PRId64", tid:%d check data in buffer from skey:%" PRId64 ", order:%d, %"PRIu64, pHandle,
+ tsdbDebug("%p uid:%" PRId64", tid:%d check data in buffer from skey:%" PRId64 ", order:%d, 0x%"PRIx64, pHandle,
pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, pCheckInfo->lastKey, pHandle->order, pHandle->qId);
// all data in mem are checked already.
@@ -986,21 +986,21 @@ static int32_t doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SBlock* pBloc
STSchema *pSchema = tsdbGetTableSchema(pCheckInfo->pTableObj);
int32_t code = tdInitDataCols(pQueryHandle->pDataCols, pSchema);
if (code != TSDB_CODE_SUCCESS) {
- tsdbError("%p failed to malloc buf for pDataCols, %"PRIu64, pQueryHandle, pQueryHandle->qId);
+ tsdbError("%p failed to malloc buf for pDataCols, 0x%"PRIx64, pQueryHandle, pQueryHandle->qId);
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
goto _error;
}
code = tdInitDataCols(pQueryHandle->rhelper.pDCols[0], pSchema);
if (code != TSDB_CODE_SUCCESS) {
- tsdbError("%p failed to malloc buf for rhelper.pDataCols[0], %"PRIu64, pQueryHandle, pQueryHandle->qId);
+ tsdbError("%p failed to malloc buf for rhelper.pDataCols[0], 0x%"PRIx64, pQueryHandle, pQueryHandle->qId);
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
goto _error;
}
code = tdInitDataCols(pQueryHandle->rhelper.pDCols[1], pSchema);
if (code != TSDB_CODE_SUCCESS) {
- tsdbError("%p failed to malloc buf for rhelper.pDataCols[1], %"PRIu64, pQueryHandle, pQueryHandle->qId);
+ tsdbError("%p failed to malloc buf for rhelper.pDataCols[1], 0x%"PRIx64, pQueryHandle, pQueryHandle->qId);
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
goto _error;
}
@@ -1036,14 +1036,14 @@ static int32_t doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SBlock* pBloc
int64_t elapsedTime = (taosGetTimestampUs() - st);
pQueryHandle->cost.blockLoadTime += elapsedTime;
- tsdbDebug("%p load file block into buffer, index:%d, brange:%"PRId64"-%"PRId64", rows:%d, elapsed time:%"PRId64 " us, %"PRIu64,
+ tsdbDebug("%p load file block into buffer, index:%d, brange:%"PRId64"-%"PRId64", rows:%d, elapsed time:%"PRId64 " us, 0x%"PRIx64,
pQueryHandle, slotIndex, pBlock->keyFirst, pBlock->keyLast, pBlock->numOfRows, elapsedTime, pQueryHandle->qId);
return TSDB_CODE_SUCCESS;
_error:
pBlock->numOfRows = 0;
- tsdbError("%p error occurs in loading file block, index:%d, brange:%"PRId64"-%"PRId64", rows:%d, %"PRIu64,
+ tsdbError("%p error occurs in loading file block, index:%d, brange:%"PRId64"-%"PRId64", rows:%d, 0x%"PRIx64,
pQueryHandle, slotIndex, pBlock->keyFirst, pBlock->keyLast, pBlock->numOfRows, pQueryHandle->qId);
return terrno;
}
@@ -1066,7 +1066,7 @@ static int32_t handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SBlock* p
assert(cur->pos >= 0 && cur->pos <= binfo.rows);
TSKEY key = (row != NULL)? dataRowKey(row):TSKEY_INITIAL_VAL;
- tsdbDebug("%p key in mem:%"PRId64", %"PRIu64, pQueryHandle, key, pQueryHandle->qId);
+ tsdbDebug("%p key in mem:%"PRId64", 0x%"PRIx64, pQueryHandle, key, pQueryHandle->qId);
if ((ASCENDING_TRAVERSE(pQueryHandle->order) && (key != TSKEY_INITIAL_VAL && key <= binfo.window.ekey)) ||
(!ASCENDING_TRAVERSE(pQueryHandle->order) && (key != TSKEY_INITIAL_VAL && key >= binfo.window.skey))) {
@@ -1406,7 +1406,11 @@ static void copyOneRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
SET_DOUBLE_PTR(pData, value);
break;
case TSDB_DATA_TYPE_TIMESTAMP:
- *(TSKEY *)pData = tdGetKey(*(TKEY *)value);
+ if (pColInfo->info.colId == PRIMARYKEY_TIMESTAMP_COL_INDEX) {
+ *(TSKEY *)pData = tdGetKey(*(TKEY *)value);
+ } else {
+ *(TSKEY *)pData = *(TSKEY *)value;
+ }
break;
default:
memcpy(pData, value, pColInfo->info.bytes);
@@ -1547,7 +1551,7 @@ static void copyAllRemainRowsFromFileBlock(STsdbQueryHandle* pQueryHandle, STabl
updateInfoAfterMerge(pQueryHandle, pCheckInfo, numOfRows, pos);
doCheckGeneratedBlockRange(pQueryHandle);
- tsdbDebug("%p uid:%" PRIu64",tid:%d data block created, mixblock:%d, brange:%"PRIu64"-%"PRIu64" rows:%d, %"PRIu64,
+ tsdbDebug("%p uid:%" PRIu64",tid:%d data block created, mixblock:%d, brange:%"PRIu64"-%"PRIu64" rows:%d, 0x%"PRIx64,
pQueryHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, cur->mixBlock, cur->win.skey,
cur->win.ekey, cur->rows, pQueryHandle->qId);
}
@@ -1601,7 +1605,7 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
int32_t endPos = getEndPosInDataBlock(pQueryHandle, &blockInfo);
tsdbDebug("%p uid:%" PRIu64",tid:%d start merge data block, file block range:%"PRIu64"-%"PRIu64" rows:%d, start:%d,"
- "end:%d, %"PRIu64,
+ "end:%d, 0x%"PRIx64,
pQueryHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, blockInfo.window.skey, blockInfo.window.ekey,
blockInfo.rows, cur->pos, endPos, pQueryHandle->qId);
@@ -1743,7 +1747,7 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
updateInfoAfterMerge(pQueryHandle, pCheckInfo, numOfRows, pos);
doCheckGeneratedBlockRange(pQueryHandle);
- tsdbDebug("%p uid:%" PRIu64",tid:%d data block created, mixblock:%d, brange:%"PRIu64"-%"PRIu64" rows:%d, %"PRIu64,
+ tsdbDebug("%p uid:%" PRIu64",tid:%d data block created, mixblock:%d, brange:%"PRIu64"-%"PRIu64" rows:%d, 0x%"PRIx64,
pQueryHandle, pCheckInfo->tableId.uid, pCheckInfo->tableId.tid, cur->mixBlock, cur->win.skey,
cur->win.ekey, cur->rows, pQueryHandle->qId);
}
@@ -1919,12 +1923,12 @@ static int32_t createDataBlocksInfo(STsdbQueryHandle* pQueryHandle, int32_t numO
memcpy(pQueryHandle->pDataBlockInfo, sup.pDataBlockInfo[0], sizeof(STableBlockInfo) * numOfBlocks);
cleanBlockOrderSupporter(&sup, numOfQualTables);
- tsdbDebug("%p create data blocks info struct completed for 1 table, %d blocks not sorted %"PRIu64, pQueryHandle, cnt,
+ tsdbDebug("%p create data blocks info struct completed for 1 table, %d blocks not sorted 0x%"PRIx64, pQueryHandle, cnt,
pQueryHandle->qId);
return TSDB_CODE_SUCCESS;
}
- tsdbDebug("%p create data blocks info struct completed, %d blocks in %d tables %"PRIu64, pQueryHandle, cnt,
+ tsdbDebug("%p create data blocks info struct completed, %d blocks in %d tables 0x%"PRIx64, pQueryHandle, cnt,
numOfQualTables, pQueryHandle->qId);
assert(cnt <= numOfBlocks && numOfQualTables <= numOfTables); // the pTableQueryInfo[j]->numOfBlocks may be 0
@@ -1961,7 +1965,7 @@ static int32_t createDataBlocksInfo(STsdbQueryHandle* pQueryHandle, int32_t numO
* }
*/
- tsdbDebug("%p %d data blocks sort completed, %"PRIu64, pQueryHandle, cnt, pQueryHandle->qId);
+ tsdbDebug("%p %d data blocks sort completed, 0x%"PRIx64, pQueryHandle, cnt, pQueryHandle->qId);
cleanBlockOrderSupporter(&sup, numOfTables);
free(pTree);
@@ -2019,7 +2023,7 @@ static int32_t getFirstFileDataBlock(STsdbQueryHandle* pQueryHandle, bool* exist
if ((ASCENDING_TRAVERSE(pQueryHandle->order) && win.skey > pQueryHandle->window.ekey) ||
(!ASCENDING_TRAVERSE(pQueryHandle->order) && win.ekey < pQueryHandle->window.ekey)) {
tsdbUnLockFS(REPO_FS(pQueryHandle->pTsdb));
- tsdbDebug("%p remain files are not qualified for qrange:%" PRId64 "-%" PRId64 ", ignore, %"PRIu64, pQueryHandle,
+ tsdbDebug("%p remain files are not qualified for qrange:%" PRId64 "-%" PRId64 ", ignore, 0x%"PRIx64, pQueryHandle,
pQueryHandle->window.skey, pQueryHandle->window.ekey, pQueryHandle->qId);
pQueryHandle->pFileGroup = NULL;
assert(pQueryHandle->numOfBlocks == 0);
@@ -2043,7 +2047,7 @@ static int32_t getFirstFileDataBlock(STsdbQueryHandle* pQueryHandle, bool* exist
break;
}
- tsdbDebug("%p %d blocks found in file for %d table(s), fid:%d, %"PRIu64, pQueryHandle, numOfBlocks, numOfTables,
+ tsdbDebug("%p %d blocks found in file for %d table(s), fid:%d, 0x%"PRIx64, pQueryHandle, numOfBlocks, numOfTables,
pQueryHandle->pFileGroup->fid, pQueryHandle->qId);
assert(numOfBlocks >= 0);
@@ -2135,7 +2139,7 @@ int32_t tsdbGetFileBlocksDistInfo(TsdbQueryHandleT* queryHandle, STableBlockDist
if ((ASCENDING_TRAVERSE(pQueryHandle->order) && win.skey > pQueryHandle->window.ekey) ||
(!ASCENDING_TRAVERSE(pQueryHandle->order) && win.ekey < pQueryHandle->window.ekey)) {
tsdbUnLockFS(REPO_FS(pQueryHandle->pTsdb));
- tsdbDebug("%p remain files are not qualified for qrange:%" PRId64 "-%" PRId64 ", ignore, %"PRIu64, pQueryHandle,
+ tsdbDebug("%p remain files are not qualified for qrange:%" PRId64 "-%" PRId64 ", ignore, 0x%"PRIx64, pQueryHandle,
pQueryHandle->window.skey, pQueryHandle->window.ekey, pQueryHandle->qId);
pQueryHandle->pFileGroup = NULL;
break;
@@ -2159,7 +2163,7 @@ int32_t tsdbGetFileBlocksDistInfo(TsdbQueryHandleT* queryHandle, STableBlockDist
break;
}
- tsdbDebug("%p %d blocks found in file for %d table(s), fid:%d, %"PRIu64, pQueryHandle, numOfBlocks, numOfTables,
+ tsdbDebug("%p %d blocks found in file for %d table(s), fid:%d, 0x%"PRIx64, pQueryHandle, numOfBlocks, numOfTables,
pQueryHandle->pFileGroup->fid, pQueryHandle->qId);
if (numOfBlocks == 0) {
@@ -2207,7 +2211,7 @@ static int32_t getDataBlocksInFiles(STsdbQueryHandle* pQueryHandle, bool* exists
if ((!cur->mixBlock) || cur->blockCompleted) {
// all data blocks in current file has been checked already, try next file if exists
} else {
- tsdbDebug("%p continue in current data block, index:%d, pos:%d, %"PRIu64, pQueryHandle, cur->slot, cur->pos,
+ tsdbDebug("%p continue in current data block, index:%d, pos:%d, 0x%"PRIx64, pQueryHandle, cur->slot, cur->pos,
pQueryHandle->qId);
int32_t code = handleDataMergeIfNeeded(pQueryHandle, pBlockInfo->compBlock, pCheckInfo);
*exists = (pQueryHandle->realNumOfRows > 0);
@@ -2336,7 +2340,7 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
}
int64_t elapsedTime = taosGetTimestampUs() - st;
- tsdbDebug("%p build data block from cache completed, elapsed time:%"PRId64" us, numOfRows:%d, numOfCols:%d, %"PRIu64, pQueryHandle,
+ tsdbDebug("%p build data block from cache completed, elapsed time:%"PRId64" us, numOfRows:%d, numOfCols:%d, 0x%"PRIx64, pQueryHandle,
elapsedTime, numOfRows, numOfCols, pQueryHandle->qId);
return numOfRows;
@@ -3206,9 +3210,10 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons
pGroupInfo->numOfTables = (uint32_t) taosArrayGetSize(res);
pGroupInfo->pGroupList = createTableGroup(res, pTagSchema, pColIndex, numOfCols, skey);
- tsdbDebug("%p no table name/tag condition, all tables belong to one group, numOfTables:%u", tsdb, pGroupInfo->numOfTables);
- taosArrayDestroy(res);
+ tsdbDebug("%p no table name/tag condition, all tables qualified, numOfTables:%u, group:%zu", tsdb,
+ pGroupInfo->numOfTables, taosArrayGetSize(pGroupInfo->pGroupList));
+ taosArrayDestroy(res);
if (tsdbUnlockRepoMeta(tsdb) < 0) goto _error;
return ret;
}
@@ -3391,7 +3396,7 @@ void tsdbCleanupQueryHandle(TsdbQueryHandleT queryHandle) {
pQueryHandle->next = doFreeColumnInfoData(pQueryHandle->next);
SIOCostSummary* pCost = &pQueryHandle->cost;
- tsdbDebug("%p :io-cost summary: statis-info:%"PRId64" us, datablock:%" PRId64" us, check data:%"PRId64" us, %"PRIu64,
+ tsdbDebug("%p :io-cost summary: statis-info:%"PRId64" us, datablock:%" PRId64" us, check data:%"PRId64" us, 0x%"PRIx64,
pQueryHandle, pCost->statisInfoLoadTime, pCost->blockLoadTime, pCost->checkForNextTime, pQueryHandle->qId);
tfree(pQueryHandle);
diff --git a/src/util/src/tcompare.c b/src/util/src/tcompare.c
index 4d18ef14e2..354e7899c2 100644
--- a/src/util/src/tcompare.c
+++ b/src/util/src/tcompare.c
@@ -398,6 +398,10 @@ int32_t doCompare(const char* f1, const char* f2, int32_t type, size_t size) {
case TSDB_DATA_TYPE_SMALLINT: DEFAULT_COMP(GET_INT16_VAL(f1), GET_INT16_VAL(f2));
case TSDB_DATA_TYPE_TINYINT:
case TSDB_DATA_TYPE_BOOL: DEFAULT_COMP(GET_INT8_VAL(f1), GET_INT8_VAL(f2));
+ case TSDB_DATA_TYPE_UTINYINT: DEFAULT_COMP(GET_UINT8_VAL(f1), GET_UINT8_VAL(f2));
+ case TSDB_DATA_TYPE_USMALLINT: DEFAULT_COMP(GET_UINT16_VAL(f1), GET_UINT16_VAL(f2));
+ case TSDB_DATA_TYPE_UINT: DEFAULT_COMP(GET_UINT32_VAL(f1), GET_UINT32_VAL(f2));
+ case TSDB_DATA_TYPE_UBIGINT: DEFAULT_COMP(GET_UINT64_VAL(f1), GET_UINT64_VAL(f2));
case TSDB_DATA_TYPE_NCHAR: {
tstr* t1 = (tstr*) f1;
tstr* t2 = (tstr*) f2;
diff --git a/src/util/src/tcrc32c.c b/src/util/src/tcrc32c.c
index 502116f9c2..054b8f8171 100644
--- a/src/util/src/tcrc32c.c
+++ b/src/util/src/tcrc32c.c
@@ -736,7 +736,7 @@ static uint32_t table[16][256] = {
0x9c221d09, 0x6e2e10f7, 0x7dd67004, 0x8fda7dfa}
};
-#ifndef _TD_ARM_
+#if !defined(_TD_ARM_) && !defined(_TD_MIPS_)
static uint32_t long_shifts[4][256] = {
{0x00000000, 0xe040e0ac, 0xc56db7a9, 0x252d5705, 0x8f3719a3, 0x6f77f90f,
0x4a5aae0a, 0xaa1a4ea6, 0x1b8245b7, 0xfbc2a51b, 0xdeeff21e, 0x3eaf12b2,
@@ -1187,7 +1187,7 @@ uint32_t crc32c_sf(uint32_t crci, crc_stream input, size_t length) {
}
return (uint32_t)crc ^ 0xffffffff;
}
-#ifndef _TD_ARM_
+#if !defined(_TD_ARM_) && !defined(_TD_MIPS_)
/* Apply the zeros operator table to crc. */
static uint32_t shift_crc(uint32_t shift_table[][256], uint32_t crc) {
return shift_table[0][crc & 0xff] ^ shift_table[1][(crc >> 8) & 0xff] ^
@@ -1198,7 +1198,7 @@ static uint32_t shift_crc(uint32_t shift_table[][256], uint32_t crc) {
version. Otherwise, use the software version. */
uint32_t (*crc32c)(uint32_t crci, crc_stream bytes, size_t len) = crc32c_sf;
-#ifndef _TD_ARM_
+#if !defined(_TD_ARM_) && !defined(_TD_MIPS_)
/* Compute CRC-32C using the Intel hardware instruction. */
uint32_t crc32c_hw(uint32_t crc, crc_stream buf, size_t len) {
crc_stream next = buf;
@@ -1353,7 +1353,7 @@ uint32_t crc32c_hw(uint32_t crc, crc_stream buf, size_t len) {
#endif // #ifndef _TD_ARM_
void taosResolveCRC() {
-#if defined _TD_ARM_ || defined WINDOWS
+#if defined _TD_ARM_ || defined _TD_MIPS_ || defined WINDOWS
crc32c = crc32c_sf;
#else
int sse42;
diff --git a/src/util/src/tlog.c b/src/util/src/tlog.c
index 448bb3ecd1..7f127fc396 100644
--- a/src/util/src/tlog.c
+++ b/src/util/src/tlog.c
@@ -416,7 +416,8 @@ void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...) {
}
}
- if (dflag & DEBUG_SCREEN) taosWrite(1, buffer, (uint32_t)len);
+ if (dflag & DEBUG_SCREEN)
+ taosWrite(1, buffer, (uint32_t)len);
if (dflag == 255) nInfo(buffer, len);
}
diff --git a/src/util/src/tnettest.c b/src/util/src/tnettest.c
index 28abad356c..131063b0de 100644
--- a/src/util/src/tnettest.c
+++ b/src/util/src/tnettest.c
@@ -291,16 +291,16 @@ static void taosNetCheckPort(uint32_t hostIp, int32_t startPort, int32_t endPort
info.port = port;
ret = taosNetCheckTcpPort(&info);
if (ret != 0) {
- uError("failed to test TCP port:%d", port);
+ printf("failed to test TCP port:%d\n", port);
} else {
- uInfo("successed to test TCP port:%d", port);
+ printf("successed to test TCP port:%d\n", port);
}
ret = taosNetCheckUdpPort(&info);
if (ret != 0) {
- uError("failed to test UDP port:%d", port);
+ printf("failed to test UDP port:%d\n", port);
} else {
- uInfo("successed to test UDP port:%d", port);
+ printf("successed to test UDP port:%d\n", port);
}
}
}
@@ -464,9 +464,9 @@ static void taosNetTestRpc(char *host, int32_t startPort, int32_t pkgLen) {
int32_t ret = taosNetCheckRpc(host, port, sendpkgLen, spi, NULL);
if (ret < 0) {
- uError("failed to test TCP port:%d", port);
+ printf("failed to test TCP port:%d\n", port);
} else {
- uInfo("successed to test TCP port:%d", port);
+ printf("successed to test TCP port:%d\n", port);
}
if (pkgLen >= tsRpcMaxUdpSize) {
@@ -477,9 +477,9 @@ static void taosNetTestRpc(char *host, int32_t startPort, int32_t pkgLen) {
ret = taosNetCheckRpc(host, port, pkgLen, spi, NULL);
if (ret < 0) {
- uError("failed to test UDP port:%d", port);
+ printf("failed to test UDP port:%d\n", port);
} else {
- uInfo("successed to test UDP port:%d", port);
+ printf("successed to test UDP port:%d\n", port);
}
}
@@ -539,7 +539,7 @@ static void taosNetTestServer(char *host, int32_t startPort, int32_t pkgLen) {
}
void taosNetTest(char *role, char *host, int32_t port, int32_t pkgLen) {
- tscEmbedded = 1;
+// tscEmbedded = 1;
if (host == NULL) host = tsLocalFqdn;
if (port == 0) port = tsServerPort;
if (pkgLen <= 10) pkgLen = 1000;
@@ -559,5 +559,5 @@ void taosNetTest(char *role, char *host, int32_t port, int32_t pkgLen) {
taosNetTestStartup(host, port);
}
- tscEmbedded = 0;
+// tscEmbedded = 0;
}
diff --git a/src/util/src/ttimer.c b/src/util/src/ttimer.c
index 9833449777..865e1159c1 100644
--- a/src/util/src/ttimer.c
+++ b/src/util/src/ttimer.c
@@ -538,7 +538,7 @@ static void taosTmrModuleInit(void) {
void* taosTmrInit(int maxNumOfTmrs, int resolution, int longest, const char* label) {
const char* ret = monotonicInit();
- tmrInfo("ttimer monotonic clock source:%s", ret);
+ tmrDebug("ttimer monotonic clock source:%s", ret);
pthread_once(&tmrModuleInit, taosTmrModuleInit);
diff --git a/src/vnode/src/vnodeRead.c b/src/vnode/src/vnodeRead.c
index b562a4c255..b28bdbf130 100644
--- a/src/vnode/src/vnodeRead.c
+++ b/src/vnode/src/vnodeRead.c
@@ -183,7 +183,7 @@ static int32_t vnodeDumpQueryResult(SRspRet *pRet, void *pVnode, uint64_t qId, v
}
} else {
*freeHandle = true;
- vTrace("QInfo:%"PRIu64"-%p exec completed, free handle:%d", qId, *handle, *freeHandle);
+ vTrace("QInfo:0x%"PRIx64"-%p exec completed, free handle:%d", qId, *handle, *freeHandle);
}
} else {
SRetrieveTableRsp *pRsp = (SRetrieveTableRsp *)rpcMallocCont(sizeof(SRetrieveTableRsp));
@@ -244,7 +244,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
if (handle == NULL) { // failed to register qhandle
pRsp->code = terrno;
terrno = 0;
- vError("vgId:%d, QInfo:%"PRIu64 "-%p register qhandle failed, return to app, code:%s", pVnode->vgId, qId, (void *)pQInfo,
+ vError("vgId:%d, QInfo:0x%"PRIx64 "-%p register qhandle failed, return to app, code:%s", pVnode->vgId, qId, (void *)pQInfo,
tstrerror(pRsp->code));
qDestroyQueryInfo(pQInfo); // destroy it directly
return pRsp->code;
@@ -255,7 +255,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
if (handle != NULL &&
vnodeNotifyCurrentQhandle(pRead->rpcHandle, qId, *handle, pVnode->vgId) != TSDB_CODE_SUCCESS) {
- vError("vgId:%d, QInfo:%"PRIu64 "-%p, query discarded since link is broken, %p", pVnode->vgId, qId, *handle,
+ vError("vgId:%d, QInfo:0x%"PRIx64 "-%p, query discarded since link is broken, %p", pVnode->vgId, qId, *handle,
pRead->rpcHandle);
pRsp->code = TSDB_CODE_RPC_NETWORK_UNAVAIL;
qReleaseQInfo(pVnode->qMgmt, (void **)&handle, true);
@@ -266,7 +266,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
}
if (handle != NULL) {
- vTrace("vgId:%d, QInfo:%"PRIu64 "-%p, dnode query msg disposed, create qhandle and returns to app", vgId, qId, *handle);
+ vTrace("vgId:%d, QInfo:0x%"PRIx64 "-%p, dnode query msg disposed, create qhandle and returns to app", vgId, qId, *handle);
code = vnodePutItemIntoReadQueue(pVnode, handle, pRead->rpcHandle);
if (code != TSDB_CODE_SUCCESS) {
pRsp->code = code;
@@ -331,7 +331,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
pRetrieve->free = htons(pRetrieve->free);
pRetrieve->qId = htobe64(pRetrieve->qId);
- vTrace("vgId:%d, qId:%" PRIu64 ", retrieve msg is disposed, free:%d, conn:%p", pVnode->vgId, pRetrieve->qId,
+ vTrace("vgId:%d, qId:0x%" PRIx64 ", retrieve msg is disposed, free:%d, conn:%p", pVnode->vgId, pRetrieve->qId,
pRetrieve->free, pRead->rpcHandle);
memset(pRet, 0, sizeof(SRspRet));
@@ -414,7 +414,7 @@ int32_t vnodeNotifyCurrentQhandle(void *handle, uint64_t qId, void *qhandle, int
pMsg->header.vgId = htonl(vgId);
pMsg->header.contLen = htonl(sizeof(SRetrieveTableMsg));
- vTrace("QInfo:%"PRIu64"-%p register qhandle to connect:%p", qId, qhandle, handle);
+ vTrace("QInfo:0x%"PRIx64"-%p register qhandle to connect:%p", qId, qhandle, handle);
return rpcReportProgress(handle, (char *)pMsg, sizeof(SRetrieveTableMsg));
}
diff --git a/tests/examples/C#/C#checker/C#checker.cs b/tests/examples/C#/C#checker/C#checker.cs
index 24b7060b14..80fa3b8386 100644
--- a/tests/examples/C#/C#checker/C#checker.cs
+++ b/tests/examples/C#/C#checker/C#checker.cs
@@ -20,358 +20,367 @@ using System.Runtime.InteropServices;
using System.Collections;
namespace TDengineDriver
-{
- class TDengineTest
- {
- //connect parameters
- private string host;
- private string configDir;
- private string user;
- private string password;
- private short port = 0;
-
- //sql parameters
- private string dbName;
- private string tbName;
-
-
- private bool isInsertData;
- private bool isQueryData;
-
- private long tableCount;
- private long totalRows;
- private long batchRows;
- private long beginTimestamp = 1551369600000L;
-
- private IntPtr conn = IntPtr.Zero;
- private long rowsInserted = 0;
-
- static void Main(string[] args)
- {
- TDengineTest tester = new TDengineTest();
- tester.ReadArgument(args);
-
-
- tester.InitTDengine();
- tester.ConnectTDengine();
+{
+ class TDengineTest
+ {
+ //connect parameters
+ private string host;
+ private string configDir;
+ private string user;
+ private string password;
+ private short port = 0;
+
+ //sql parameters
+ private string dbName;
+ private string tbName;
+
+
+ private bool isInsertData;
+ private bool isQueryData;
+
+ private long tableCount;
+ private long totalRows;
+ private long batchRows;
+ private long beginTimestamp = 1551369600000L;
+
+ private IntPtr conn = IntPtr.Zero;
+ private long rowsInserted = 0;
+
+ static void Main(string[] args)
+ {
+ TDengineTest tester = new TDengineTest();
+ tester.ReadArgument(args);
+
+
+ tester.InitTDengine();
+ tester.ConnectTDengine();
tester.createDatabase();
- tester.useDatabase();
+ tester.useDatabase();
tester.checkDropTable();
tester.createTable();
tester.checkInsert();
tester.checkSelect();
- tester.checkDropTable();
-
- tester.CloseConnection();
-
-
-
- }
-
- public long GetArgumentAsLong(String[] argv, String argName, int minVal, int maxVal, int defaultValue)
- {
- int argc = argv.Length;
- for (int i = 0; i < argc; ++i)
- {
- if (argName != argv[i])
- {
- continue;
- }
- if (i < argc - 1)
- {
- String tmp = argv[i + 1];
- if (tmp[0] == '-')
- {
- Console.WriteLine("option {0:G} requires an argument", tmp);
- ExitProgram();
- }
-
- long tmpVal = Convert.ToInt64(tmp);
- if (tmpVal < minVal || tmpVal > maxVal)
- {
- Console.WriteLine("option {0:G} should in range [{1:G}, {2:G}]", argName, minVal, maxVal);
- ExitProgram();
- }
-
- return tmpVal;
- }
- }
-
- return defaultValue;
- }
-
- public String GetArgumentAsString(String[] argv, String argName, String defaultValue)
- {
- int argc = argv.Length;
- for (int i = 0; i < argc; ++i)
- {
- if (argName != argv[i])
- {
- continue;
- }
- if (i < argc - 1)
- {
- String tmp = argv[i + 1];
- if (tmp[0] == '-')
- {
- Console.WriteLine("option {0:G} requires an argument", tmp);
- ExitProgram();
- }
- return tmp;
- }
- }
-
- return defaultValue;
- }
-
- public void PrintHelp(String[] argv)
- {
- for (int i = 0; i < argv.Length; ++i)
- {
- if ("--help" == argv[i])
- {
- String indent = " ";
- Console.WriteLine("taosTest is simple example to operate TDengine use C# Language.\n");
- Console.WriteLine("{0:G}{1:G}", indent, "-h");
- Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "TDEngine server IP address to connect");
- Console.WriteLine("{0:G}{1:G}", indent, "-u");
- Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "The TDEngine user name to use when connecting to the server, default is root");
- Console.WriteLine("{0:G}{1:G}", indent, "-p");
- Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "The TDEngine user name to use when connecting to the server, default is taosdata");
- Console.WriteLine("{0:G}{1:G}", indent, "-d");
- Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Database used to create table or import data, default is db");
- Console.WriteLine("{0:G}{1:G}", indent, "-s");
- Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Super Tables used to create table, default is mt");
- Console.WriteLine("{0:G}{1:G}", indent, "-t");
- Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Table prefixs, default is t");
- Console.WriteLine("{0:G}{1:G}", indent, "-w");
- Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Whether to insert data");
- Console.WriteLine("{0:G}{1:G}", indent, "-r");
- Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Whether to query data");
- Console.WriteLine("{0:G}{1:G}", indent, "-n");
- Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "How many Tables to create, default is 10");
- Console.WriteLine("{0:G}{1:G}", indent, "-b");
- Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "How many rows per insert batch, default is 10");
- Console.WriteLine("{0:G}{1:G}", indent, "-i");
- Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "How many rows to insert, default is 100");
- Console.WriteLine("{0:G}{1:G}", indent, "-c");
- Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Configuration directory");
-
- ExitProgram();
- }
- }
- }
-
- public void ReadArgument(String[] argv)
- {
- PrintHelp(argv);
- host = this.GetArgumentAsString(argv, "-h", "127.0.0.1");
- user = this.GetArgumentAsString(argv, "-u", "root");
- password = this.GetArgumentAsString(argv, "-p", "taosdata");
- dbName = this.GetArgumentAsString(argv, "-db", "test");
- tbName = this.GetArgumentAsString(argv, "-s", "weather");
-
- isInsertData = this.GetArgumentAsLong(argv, "-w", 0, 1, 1) != 0;
- isQueryData = this.GetArgumentAsLong(argv, "-r", 0, 1, 1) != 0;
- tableCount = this.GetArgumentAsLong(argv, "-n", 1, 10000, 10);
- batchRows = this.GetArgumentAsLong(argv, "-b", 1, 1000, 500);
- totalRows = this.GetArgumentAsLong(argv, "-i", 1, 10000000, 10000);
- configDir = this.GetArgumentAsString(argv, "-c", "C:/TDengine/cfg");
- }
-
- public void InitTDengine()
- {
- TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, this.configDir);
- TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60");
- TDengine.Init();
- Console.WriteLine("get connection starting...");
- }
-
- public void ConnectTDengine()
- {
- string db = "";
- this.conn = TDengine.Connect(this.host, this.user, this.password, db, this.port);
- if (this.conn == IntPtr.Zero)
- {
- Console.WriteLine("connection failed: " + this.host);
- ExitProgram();
- }
- else
- {
- Console.WriteLine("[ OK ] Connection established.");
- }
- }
- public void createDatabase()
- {
- StringBuilder sql = new StringBuilder();
- sql.Append("create database if not exists ").Append(this.dbName);
- execute(sql.ToString());
- }
- public void useDatabase()
- {
- StringBuilder sql = new StringBuilder();
- sql.Append("use ").Append(this.dbName);
- execute(sql.ToString());
- }
- public void checkSelect()
- {
- StringBuilder sql = new StringBuilder();
- sql.Append("select * from test.weather");
- execute(sql.ToString());
- }
- public void createTable()
- {
- StringBuilder sql = new StringBuilder();
- sql.Append("create table if not exists ").Append(this.dbName).Append(".").Append(this.tbName).Append("(ts timestamp, temperature float, humidity int)");
- execute(sql.ToString());
- }
- public void checkInsert()
- {
- StringBuilder sql = new StringBuilder();
- sql.Append("insert into test.weather (ts, temperature, humidity) values(now, 20.5, 34)");
- execute(sql.ToString());
- }
- public void checkDropTable()
- {
- StringBuilder sql = new StringBuilder();
- sql.Append("drop table if exists ").Append(this.dbName).Append(".").Append(this.tbName).Append("");
- execute(sql.ToString());
- }
- public void execute(string sql)
- {
- DateTime dt1 = DateTime.Now;
- IntPtr res = TDengine.Query(this.conn, sql.ToString());
- DateTime dt2 = DateTime.Now;
- TimeSpan span = dt2 - dt1;
-
- if (res != IntPtr.Zero)
- {
- Console.WriteLine("[OK] time cost: " + span.ToString() + "ms, execute statement ====> " + sql.ToString());
- }
- else
- {
- Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
- ExitProgram();
- }
- TDengine.FreeResult(res);
- }
-
- public void ExecuteQuery(string sql)
- {
-
- DateTime dt1 = DateTime.Now;
- long queryRows = 0;
- IntPtr res = TDengine.Query(conn, sql);
- if (res == IntPtr.Zero)
- {
- Console.WriteLine(sql + " failure, reason: " + TDengine.Error(res));
- ExitProgram();
- }
- DateTime dt2 = DateTime.Now;
- TimeSpan span = dt2 - dt1;
- Console.WriteLine("[OK] time cost: " + span.ToString() + "ms, execute statement ====> " + sql.ToString());
- int fieldCount = TDengine.FieldCount(res);
-
- List metas = TDengine.FetchFields(res);
- for (int j = 0; j < metas.Count; j++)
- {
- TDengineMeta meta = (TDengineMeta)metas[j];
- }
-
- IntPtr rowdata;
- StringBuilder builder = new StringBuilder();
- while ((rowdata = TDengine.FetchRows(res)) != IntPtr.Zero)
- {
- queryRows++;
- for (int fields = 0; fields < fieldCount; ++fields)
- {
- TDengineMeta meta = metas[fields];
- int offset = IntPtr.Size * fields;
- IntPtr data = Marshal.ReadIntPtr(rowdata, offset);
-
- builder.Append("---");
-
- if (data == IntPtr.Zero)
- {
- builder.Append("NULL");
- continue;
- }
-
- switch ((TDengineDataType)meta.type)
- {
- case TDengineDataType.TSDB_DATA_TYPE_BOOL:
- bool v1 = Marshal.ReadByte(data) == 0 ? false : true;
- builder.Append(v1);
- break;
- case TDengineDataType.TSDB_DATA_TYPE_TINYINT:
- byte v2 = Marshal.ReadByte(data);
- builder.Append(v2);
- break;
- case TDengineDataType.TSDB_DATA_TYPE_SMALLINT:
- short v3 = Marshal.ReadInt16(data);
- builder.Append(v3);
- break;
- case TDengineDataType.TSDB_DATA_TYPE_INT:
- int v4 = Marshal.ReadInt32(data);
- builder.Append(v4);
- break;
- case TDengineDataType.TSDB_DATA_TYPE_BIGINT:
- long v5 = Marshal.ReadInt64(data);
- builder.Append(v5);
- break;
- case TDengineDataType.TSDB_DATA_TYPE_FLOAT:
- float v6 = (float)Marshal.PtrToStructure(data, typeof(float));
- builder.Append(v6);
- break;
- case TDengineDataType.TSDB_DATA_TYPE_DOUBLE:
- double v7 = (double)Marshal.PtrToStructure(data, typeof(double));
- builder.Append(v7);
- break;
- case TDengineDataType.TSDB_DATA_TYPE_BINARY:
- string v8 = Marshal.PtrToStringAnsi(data);
- builder.Append(v8);
- break;
- case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP:
- long v9 = Marshal.ReadInt64(data);
- builder.Append(v9);
- break;
- case TDengineDataType.TSDB_DATA_TYPE_NCHAR:
- string v10 = Marshal.PtrToStringAnsi(data);
- builder.Append(v10);
- break;
- }
- }
- builder.Append("---");
-
- if (queryRows <= 10)
- {
- Console.WriteLine(builder.ToString());
- }
- builder.Clear();
- }
-
- if (TDengine.ErrorNo(res) != 0)
- {
- Console.Write("Query is not complete, Error {0:G}", TDengine.ErrorNo(res), TDengine.Error(res));
- }
-
- TDengine.FreeResult(res);
-
- }
-
- public void CloseConnection()
- {
- if (this.conn != IntPtr.Zero)
- {
- TDengine.Close(this.conn);
- Console.WriteLine("connection closed.");
- }
- }
-
- static void ExitProgram()
- {
- TDengine.Cleanup();
- System.Environment.Exit(0);
- }
+ tester.checkDropTable();
+
+ tester.CloseConnection();
+
+
+
+ }
+
+ public long GetArgumentAsLong(String[] argv, String argName, int minVal, int maxVal, int defaultValue)
+ {
+ int argc = argv.Length;
+ for (int i = 0; i < argc; ++i)
+ {
+ if (argName != argv[i])
+ {
+ continue;
+ }
+ if (i < argc - 1)
+ {
+ String tmp = argv[i + 1];
+ if (tmp[0] == '-')
+ {
+ Console.WriteLine("option {0:G} requires an argument", tmp);
+ ExitProgram();
+ }
+
+ long tmpVal = Convert.ToInt64(tmp);
+ if (tmpVal < minVal || tmpVal > maxVal)
+ {
+ Console.WriteLine("option {0:G} should in range [{1:G}, {2:G}]", argName, minVal, maxVal);
+ ExitProgram();
+ }
+
+ return tmpVal;
+ }
+ }
+
+ return defaultValue;
+ }
+
+ public String GetArgumentAsString(String[] argv, String argName, String defaultValue)
+ {
+ int argc = argv.Length;
+ for (int i = 0; i < argc; ++i)
+ {
+ if (argName != argv[i])
+ {
+ continue;
+ }
+ if (i < argc - 1)
+ {
+ String tmp = argv[i + 1];
+ if (tmp[0] == '-')
+ {
+ Console.WriteLine("option {0:G} requires an argument", tmp);
+ ExitProgram();
+ }
+ return tmp;
+ }
+ }
+
+ return defaultValue;
+ }
+
+ public void PrintHelp(String[] argv)
+ {
+ for (int i = 0; i < argv.Length; ++i)
+ {
+ if ("--help" == argv[i])
+ {
+ String indent = " ";
+ Console.WriteLine("taosTest is simple example to operate TDengine use C# Language.\n");
+ Console.WriteLine("{0:G}{1:G}", indent, "-h");
+ Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "TDEngine server IP address to connect");
+ Console.WriteLine("{0:G}{1:G}", indent, "-u");
+ Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "The TDEngine user name to use when connecting to the server, default is root");
+ Console.WriteLine("{0:G}{1:G}", indent, "-p");
+ Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "The TDEngine user name to use when connecting to the server, default is taosdata");
+ Console.WriteLine("{0:G}{1:G}", indent, "-d");
+ Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Database used to create table or import data, default is db");
+ Console.WriteLine("{0:G}{1:G}", indent, "-s");
+ Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Super Tables used to create table, default is mt");
+ Console.WriteLine("{0:G}{1:G}", indent, "-t");
+ Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Table prefixs, default is t");
+ Console.WriteLine("{0:G}{1:G}", indent, "-w");
+ Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Whether to insert data");
+ Console.WriteLine("{0:G}{1:G}", indent, "-r");
+ Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Whether to query data");
+ Console.WriteLine("{0:G}{1:G}", indent, "-n");
+ Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "How many Tables to create, default is 10");
+ Console.WriteLine("{0:G}{1:G}", indent, "-b");
+ Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "How many rows per insert batch, default is 10");
+ Console.WriteLine("{0:G}{1:G}", indent, "-i");
+ Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "How many rows to insert, default is 100");
+ Console.WriteLine("{0:G}{1:G}", indent, "-c");
+ Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Configuration directory");
+
+ ExitProgram();
+ }
+ }
+ }
+
+ public void ReadArgument(String[] argv)
+ {
+ PrintHelp(argv);
+ host = this.GetArgumentAsString(argv, "-h", "127.0.0.1");
+ user = this.GetArgumentAsString(argv, "-u", "root");
+ password = this.GetArgumentAsString(argv, "-p", "taosdata");
+ dbName = this.GetArgumentAsString(argv, "-db", "test");
+ tbName = this.GetArgumentAsString(argv, "-s", "weather");
+
+ isInsertData = this.GetArgumentAsLong(argv, "-w", 0, 1, 1) != 0;
+ isQueryData = this.GetArgumentAsLong(argv, "-r", 0, 1, 1) != 0;
+ tableCount = this.GetArgumentAsLong(argv, "-n", 1, 10000, 10);
+ batchRows = this.GetArgumentAsLong(argv, "-b", 1, 1000, 500);
+ totalRows = this.GetArgumentAsLong(argv, "-i", 1, 10000000, 10000);
+ configDir = this.GetArgumentAsString(argv, "-c", "C:/TDengine/cfg");
+ }
+
+ public void InitTDengine()
+ {
+ TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, this.configDir);
+ TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60");
+ TDengine.Init();
+ Console.WriteLine("get connection starting...");
+ }
+
+ public void ConnectTDengine()
+ {
+ string db = "";
+ this.conn = TDengine.Connect(this.host, this.user, this.password, db, this.port);
+ if (this.conn == IntPtr.Zero)
+ {
+ Console.WriteLine("connection failed: " + this.host);
+ ExitProgram();
+ }
+ else
+ {
+ Console.WriteLine("[ OK ] Connection established.");
+ }
+ }
+ public void createDatabase()
+ {
+ StringBuilder sql = new StringBuilder();
+ sql.Append("create database if not exists ").Append(this.dbName);
+ execute(sql.ToString());
+ }
+ public void useDatabase()
+ {
+ StringBuilder sql = new StringBuilder();
+ sql.Append("use ").Append(this.dbName);
+ execute(sql.ToString());
+ }
+ public void checkSelect()
+ {
+ StringBuilder sql = new StringBuilder();
+ sql.Append("select * from test.weather");
+ execute(sql.ToString());
+ }
+ public void createTable()
+ {
+ StringBuilder sql = new StringBuilder();
+ sql.Append("create table if not exists ").Append(this.dbName).Append(".").Append(this.tbName).Append("(ts timestamp, temperature float, humidity int)");
+ execute(sql.ToString());
+ }
+ public void checkInsert()
+ {
+ StringBuilder sql = new StringBuilder();
+ sql.Append("insert into test.weather (ts, temperature, humidity) values(now, 20.5, 34)");
+ execute(sql.ToString());
+ }
+ public void checkDropTable()
+ {
+ StringBuilder sql = new StringBuilder();
+ sql.Append("drop table if exists ").Append(this.dbName).Append(".").Append(this.tbName).Append("");
+ execute(sql.ToString());
+ }
+ public void execute(string sql)
+ {
+ DateTime dt1 = DateTime.Now;
+ IntPtr res = TDengine.Query(this.conn, sql.ToString());
+ DateTime dt2 = DateTime.Now;
+ TimeSpan span = dt2 - dt1;
+
+ if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
+ {
+ Console.Write(sql.ToString() + " failure, ");
+ if (res != IntPtr.Zero) {
+ Console.Write("reason: " + TDengine.Error(res));
+ }
+ Console.WriteLine("");
+ ExitProgram();
+ }
+ else
+ {
+ Console.WriteLine(sql.ToString() + " success");
+ }
+ TDengine.FreeResult(res);
+ }
+
+ public void ExecuteQuery(string sql)
+ {
+
+ DateTime dt1 = DateTime.Now;
+ long queryRows = 0;
+ IntPtr res = TDengine.Query(conn, sql);
+ if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
+ {
+ Console.Write(sql.ToString() + " failure, ");
+ if (res != IntPtr.Zero) {
+ Console.Write("reason: " + TDengine.Error(res));
+ }
+ Console.WriteLine("");
+ ExitProgram();
+ }
+ DateTime dt2 = DateTime.Now;
+ TimeSpan span = dt2 - dt1;
+ Console.WriteLine("[OK] time cost: " + span.ToString() + "ms, execute statement ====> " + sql.ToString());
+ int fieldCount = TDengine.FieldCount(res);
+
+ List metas = TDengine.FetchFields(res);
+ for (int j = 0; j < metas.Count; j++)
+ {
+ TDengineMeta meta = (TDengineMeta)metas[j];
+ }
+
+ IntPtr rowdata;
+ StringBuilder builder = new StringBuilder();
+ while ((rowdata = TDengine.FetchRows(res)) != IntPtr.Zero)
+ {
+ queryRows++;
+ for (int fields = 0; fields < fieldCount; ++fields)
+ {
+ TDengineMeta meta = metas[fields];
+ int offset = IntPtr.Size * fields;
+ IntPtr data = Marshal.ReadIntPtr(rowdata, offset);
+
+ builder.Append("---");
+
+ if (data == IntPtr.Zero)
+ {
+ builder.Append("NULL");
+ continue;
+ }
+
+ switch ((TDengineDataType)meta.type)
+ {
+ case TDengineDataType.TSDB_DATA_TYPE_BOOL:
+ bool v1 = Marshal.ReadByte(data) == 0 ? false : true;
+ builder.Append(v1);
+ break;
+ case TDengineDataType.TSDB_DATA_TYPE_TINYINT:
+ byte v2 = Marshal.ReadByte(data);
+ builder.Append(v2);
+ break;
+ case TDengineDataType.TSDB_DATA_TYPE_SMALLINT:
+ short v3 = Marshal.ReadInt16(data);
+ builder.Append(v3);
+ break;
+ case TDengineDataType.TSDB_DATA_TYPE_INT:
+ int v4 = Marshal.ReadInt32(data);
+ builder.Append(v4);
+ break;
+ case TDengineDataType.TSDB_DATA_TYPE_BIGINT:
+ long v5 = Marshal.ReadInt64(data);
+ builder.Append(v5);
+ break;
+ case TDengineDataType.TSDB_DATA_TYPE_FLOAT:
+ float v6 = (float)Marshal.PtrToStructure(data, typeof(float));
+ builder.Append(v6);
+ break;
+ case TDengineDataType.TSDB_DATA_TYPE_DOUBLE:
+ double v7 = (double)Marshal.PtrToStructure(data, typeof(double));
+ builder.Append(v7);
+ break;
+ case TDengineDataType.TSDB_DATA_TYPE_BINARY:
+ string v8 = Marshal.PtrToStringAnsi(data);
+ builder.Append(v8);
+ break;
+ case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP:
+ long v9 = Marshal.ReadInt64(data);
+ builder.Append(v9);
+ break;
+ case TDengineDataType.TSDB_DATA_TYPE_NCHAR:
+ string v10 = Marshal.PtrToStringAnsi(data);
+ builder.Append(v10);
+ break;
+ }
+ }
+ builder.Append("---");
+
+ if (queryRows <= 10)
+ {
+ Console.WriteLine(builder.ToString());
+ }
+ builder.Clear();
+ }
+
+ if (TDengine.ErrorNo(res) != 0)
+ {
+ Console.Write("Query is not complete, Error {0:G}", TDengine.ErrorNo(res), TDengine.Error(res));
+ }
+ Console.WriteLine("");
+
+ TDengine.FreeResult(res);
+
+ }
+
+ public void CloseConnection()
+ {
+ if (this.conn != IntPtr.Zero)
+ {
+ TDengine.Close(this.conn);
+ Console.WriteLine("connection closed.");
+ }
+ }
+
+ static void ExitProgram()
+ {
+ TDengine.Cleanup();
+ System.Environment.Exit(0);
+ }
}
}
diff --git a/tests/examples/C#/TDengineTest.cs b/tests/examples/C#/TDengineTest.cs
index 24c555e8d8..f4ee62527f 100644
--- a/tests/examples/C#/TDengineTest.cs
+++ b/tests/examples/C#/TDengineTest.cs
@@ -165,7 +165,7 @@ namespace TDengineDriver
public void ReadArgument(String[] argv)
{
PrintHelp(argv);
- host = this.GetArgumentAsString(argv, "-h", "192.168.100.128");
+ host = this.GetArgumentAsString(argv, "-h", "127.0.0.1");
user = this.GetArgumentAsString(argv, "-u", "root");
password = this.GetArgumentAsString(argv, "-p", "taosdata");
dbName = this.GetArgumentAsString(argv, "-d", "db");
@@ -212,42 +212,54 @@ namespace TDengineDriver
StringBuilder sql = new StringBuilder();
sql.Append("create database if not exists ").Append(this.dbName);
IntPtr res = TDengine.Query(this.conn, sql.ToString());
- if (res != IntPtr.Zero)
+ if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{
- Console.WriteLine(sql.ToString() + " success");
+ Console.Write(sql.ToString() + " failure, ");
+ if (res != IntPtr.Zero) {
+ Console.Write("reason: " + TDengine.Error(res));
+ }
+ Console.WriteLine("");
+ ExitProgram();
}
else
{
- Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
- ExitProgram();
+ Console.WriteLine(sql.ToString() + " success");
}
TDengine.FreeResult(res);
sql.Clear();
sql.Append("use ").Append(this.dbName);
res = TDengine.Query(this.conn, sql.ToString());
- if (res != IntPtr.Zero)
+ if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{
- Console.WriteLine(sql.ToString() + " success");
+ Console.Write(sql.ToString() + " failure, ");
+ if (res != IntPtr.Zero) {
+ Console.Write("reason: " + TDengine.Error(res));
+ }
+ Console.WriteLine("");
+ ExitProgram();
}
else
{
- Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
- ExitProgram();
+ Console.WriteLine(sql.ToString() + " success");
}
TDengine.FreeResult(res);
sql.Clear();
sql.Append("create table if not exists ").Append(this.stableName).Append("(ts timestamp, v1 bool, v2 tinyint, v3 smallint, v4 int, v5 bigint, v6 float, v7 double, v8 binary(10), v9 nchar(10)) tags(t1 int)");
res = TDengine.Query(this.conn, sql.ToString());
- if (res != IntPtr.Zero)
+ if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{
- Console.WriteLine(sql.ToString() + " success");
+ Console.Write(sql.ToString() + " failure, ");
+ if (res != IntPtr.Zero) {
+ Console.Write("reason: " + TDengine.Error(res));
+ }
+ Console.WriteLine("");
+ ExitProgram();
}
else
{
- Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
- ExitProgram();
+ Console.WriteLine(sql.ToString() + " success");
}
TDengine.FreeResult(res);
@@ -257,14 +269,18 @@ namespace TDengineDriver
sql = sql.Append("create table if not exists ").Append(this.tablePrefix).Append(i)
.Append(" using ").Append(this.stableName).Append(" tags(").Append(i).Append(")");
res = TDengine.Query(this.conn, sql.ToString());
- if (res != IntPtr.Zero)
+ if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{
- Console.WriteLine(sql.ToString() + " success");
+ Console.Write(sql.ToString() + " failure, ");
+ if (res != IntPtr.Zero) {
+ Console.Write("reason: " + TDengine.Error(res));
+ }
+ Console.WriteLine("");
+ ExitProgram();
}
else
{
- Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
- ExitProgram();
+ Console.WriteLine(sql.ToString() + " success");
}
TDengine.FreeResult(res);
}
@@ -298,9 +314,13 @@ namespace TDengineDriver
.Append(", 5, 6, 7, 'abc', 'def')");
}
IntPtr res = TDengine.Query(this.conn, sql.ToString());
- if (res == IntPtr.Zero)
+ if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{
- Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
+ Console.Write(sql.ToString() + " failure, ");
+ if (res != IntPtr.Zero) {
+ Console.Write("reason: " + TDengine.Error(res));
+ }
+ Console.WriteLine("");
}
int affectRows = TDengine.AffectRows(res);
@@ -326,16 +346,20 @@ namespace TDengineDriver
System.DateTime start = new System.DateTime();
long queryRows = 0;
-
+
for (int i = 0; i < 1/*this.tableCount*/; ++i)
{
String sql = "select * from " + this.dbName + "." + tablePrefix + i;
Console.WriteLine(sql);
IntPtr res = TDengine.Query(conn, sql);
- if (res == IntPtr.Zero)
+ if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{
- Console.WriteLine(sql + " failure, reason: " + TDengine.Error(res));
+ Console.Write(sql.ToString() + " failure, ");
+ if (res != IntPtr.Zero) {
+ Console.Write("reason: " + TDengine.Error(res));
+ }
+ Console.WriteLine("");
ExitProgram();
}
@@ -439,8 +463,10 @@ namespace TDengineDriver
if (TDengine.ErrorNo(res) != 0)
{
- Console.Write("Query is not complete, Error {0:G}", TDengine.ErrorNo(res), TDengine.Error(res));
+ Console.Write("Query is not complete, Error {0:G}",
+ TDengine.ErrorNo(res), TDengine.Error(res));
}
+ Console.WriteLine("");
TDengine.FreeResult(res);
}
diff --git a/tests/examples/C#/taosdemo/taosdemo.cs b/tests/examples/C#/taosdemo/taosdemo.cs
index 4fc7232ad2..e092c48f15 100644
--- a/tests/examples/C#/taosdemo/taosdemo.cs
+++ b/tests/examples/C#/taosdemo/taosdemo.cs
@@ -370,16 +370,19 @@ namespace TDengineDriver
StringBuilder sql = new StringBuilder();
sql.Append("DROP DATABASE IF EXISTS ").Append(this.dbName);
IntPtr res = TDengine.Query(this.conn, sql.ToString());
- if (res != IntPtr.Zero)
+ if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{
- VerbosePrint(sql.ToString() + " success\n");
+ Console.Write(sql.ToString() + " failure, ");
+ if (res != IntPtr.Zero) {
+ Console.Write("reason: " + TDengine.Error(res));
+ }
+ Console.WriteLine("");
+ CleanAndExitProgram(1);
}
else
{
- Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
- CleanAndExitProgram(1);
+ VerbosePrint(sql.ToString() + " success\n");
}
-
}
public void CreateDb()
@@ -387,14 +390,18 @@ namespace TDengineDriver
StringBuilder sql = new StringBuilder();
sql.Append("CREATE DATABASE IF NOT EXISTS ").Append(this.dbName).Append(" replica ").Append(this.replica).Append(" keep 36500");
IntPtr res = TDengine.Query(this.conn, sql.ToString());
- if (res != IntPtr.Zero)
+ if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{
- VerbosePrint(sql.ToString() + " success\n");
+ Console.Write(sql.ToString() + " failure, ");
+ if (res != IntPtr.Zero) {
+ Console.Write("reason: " + TDengine.Error(res));
+ }
+ Console.WriteLine("");
+ CleanAndExitProgram(1);
}
else
{
- Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
- CleanAndExitProgram(1);
+ VerbosePrint(sql.ToString() + " success\n");
}
TDengine.FreeResult(res);
}
@@ -408,14 +415,18 @@ namespace TDengineDriver
Append(this.dbName).Append(".").Append(this.stablePrefix).
Append("(ts timestamp, v1 bool, v2 tinyint, v3 smallint, v4 int, v5 bigint, v6 float, v7 double, v8 binary(10), v9 nchar(10), v10 tinyint unsigned, v11 smallint unsigned, v12 int unsigned, v13 bigint unsigned) tags(t1 int)");
IntPtr res = TDengine.Query(this.conn, sql.ToString());
- if (res != IntPtr.Zero)
+ if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{
- VerbosePrint(sql.ToString() + " success\n");
+ Console.Write(sql.ToString() + " failure, ");
+ if (res != IntPtr.Zero) {
+ Console.Write("reason: " + TDengine.Error(res));
+ }
+ Console.WriteLine("");
+ CleanAndExitProgram(1);
}
else
{
- Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
- CleanAndExitProgram(1);
+ VerbosePrint(sql.ToString() + " success\n");
}
TDengine.FreeResult(res);
}
@@ -495,9 +506,13 @@ namespace TDengineDriver
IntPtr res = TDengine.Query(conn, sql);
DebugPrintFormat("res: {0}\n", res);
- if (res == IntPtr.Zero)
+ if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{
- Console.WriteLine(sql + " failure, reason: " + TDengine.Error(res));
+ Console.Write(sql.ToString() + " failure, ");
+ if (res != IntPtr.Zero) {
+ Console.Write("reason: " + TDengine.Error(res));
+ }
+ Console.WriteLine("");
CleanAndExitProgram(1);
}
@@ -782,9 +797,13 @@ namespace TDengineDriver
}
VerbosePrint(sql.ToString() + "\n");
IntPtr res = TDengine.Query(this.conn, sql.ToString());
- if (res == IntPtr.Zero)
+ if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{
- VerbosePrint(sql.ToString() + " failure, reason: " + TDengine.Error(res) + "\n");
+ Console.Write(sql.ToString() + " failure, ");
+ if (res != IntPtr.Zero) {
+ Console.Write("reason: " + TDengine.Error(res));
+ }
+ Console.WriteLine("");
}
inserted += this.batchRows;
@@ -861,14 +880,18 @@ namespace TDengineDriver
sql = sql.Append("(ts timestamp, v1 bool, v2 tinyint, v3 smallint, v4 int, v5 bigint, v6 float, v7 double, v8 binary(10), v9 nchar(10), v10 tinyint unsigned, v11 smallint unsigned, v12 int unsigned, v13 bigint unsigned)");
}
IntPtr res = TDengine.Query(this.conn, sql.ToString());
- if (res != IntPtr.Zero)
+ if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{
- VerbosePrint(sql.ToString() + " success\n");
+ Console.Write(sql.ToString() + " failure, ");
+ if (res != IntPtr.Zero) {
+ Console.Write("reason: " + TDengine.Error(res));
+ }
+ Console.WriteLine("");
+ CleanAndExitProgram(1);
}
else
{
- VerbosePrint(sql.ToString() + " failure, reason: " + TDengine.Error(res) + "\n");
- CleanAndExitProgram(1);
+ VerbosePrint(sql.ToString() + " success\n");
}
TDengine.FreeResult(res);
}
diff --git a/tests/examples/JDBC/springbootdemo/pom.xml b/tests/examples/JDBC/springbootdemo/pom.xml
index bd5f7efbc0..6c83718896 100644
--- a/tests/examples/JDBC/springbootdemo/pom.xml
+++ b/tests/examples/JDBC/springbootdemo/pom.xml
@@ -63,9 +63,9 @@
com.taosdata.jdbc
taos-jdbcdriver
- 2.0.20
+ 2.0.28
-
+
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/SpringbootdemoApplication.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/SpringbootdemoApplication.java
index 8f30c29946..fa10f3b092 100644
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/SpringbootdemoApplication.java
+++ b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/SpringbootdemoApplication.java
@@ -7,6 +7,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@MapperScan(basePackages = {"com.taosdata.example.springbootdemo.dao"})
@SpringBootApplication
public class SpringbootdemoApplication {
+
public static void main(String[] args) {
SpringApplication.run(SpringbootdemoApplication.class, args);
}
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/controller/WeatherController.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/controller/WeatherController.java
index c153e27701..cf14f5d84a 100644
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/controller/WeatherController.java
+++ b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/controller/WeatherController.java
@@ -45,7 +45,7 @@ public class WeatherController {
* @return
*/
@PostMapping("/{temperature}/{humidity}")
- public int saveWeather(@PathVariable float temperature, @PathVariable int humidity) {
+ public int saveWeather(@PathVariable float temperature, @PathVariable float humidity) {
return weatherService.save(temperature, humidity);
}
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/domain/Weather.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/domain/Weather.java
index 255b2cdca9..c11b9a6f50 100644
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/domain/Weather.java
+++ b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/domain/Weather.java
@@ -8,8 +8,8 @@ public class Weather {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS", timezone = "GMT+8")
private Timestamp ts;
- private float temperature;
- private float humidity;
+ private Float temperature;
+ private Float humidity;
private String location;
private int groupId;
@@ -30,19 +30,19 @@ public class Weather {
this.ts = ts;
}
- public float getTemperature() {
+ public Float getTemperature() {
return temperature;
}
- public void setTemperature(float temperature) {
+ public void setTemperature(Float temperature) {
this.temperature = temperature;
}
- public float getHumidity() {
+ public Float getHumidity() {
return humidity;
}
- public void setHumidity(float humidity) {
+ public void setHumidity(Float humidity) {
this.humidity = humidity;
}
diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java
index 0aef828e1c..26d09c7d12 100644
--- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java
+++ b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java
@@ -39,7 +39,7 @@ public class WeatherService {
return weatherMapper.select(limit, offset);
}
- public int save(float temperature, int humidity) {
+ public int save(float temperature, float humidity) {
Weather weather = new Weather();
weather.setTemperature(temperature);
weather.setHumidity(humidity);
diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c
index 930a6075ca..f20c0321c4 100644
--- a/tests/examples/c/apitest.c
+++ b/tests/examples/c/apitest.c
@@ -435,11 +435,15 @@ void verify_async(TAOS* taos) {
}
void stream_callback(void *param, TAOS_RES *res, TAOS_ROW row) {
+ if (res == NULL || row == NULL) {
+ return;
+ }
+
int num_fields = taos_num_fields(res);
TAOS_FIELD* fields = taos_fetch_fields(res);
printf("got one row from stream_callback\n");
- char temp[256];
+ char temp[256] = {0};
taos_print_row(temp, row, fields, num_fields);
puts(temp);
}
diff --git a/tests/examples/go/taosdemo.go b/tests/examples/go/taosdemo.go
index 003f5aeddc..543cfcc0f6 100644
--- a/tests/examples/go/taosdemo.go
+++ b/tests/examples/go/taosdemo.go
@@ -18,6 +18,7 @@ import (
"database/sql"
"flag"
"fmt"
+ "log"
"math/rand"
"os"
"runtime"
@@ -26,8 +27,6 @@ import (
"time"
_ "github.com/taosdata/driver-go/taosSql"
-
- //"golang.org/x/sys/unix"
)
const (
@@ -48,6 +47,7 @@ type config struct {
dbName string
supTblName string
tablePrefix string
+ mode string
numOftables int
numOfRecordsPerTable int
numOfRecordsPerReq int
@@ -70,6 +70,7 @@ func init() {
flag.StringVar(&configPara.password, "P", "taosdata", "The password to use when connecting to the server.")
flag.StringVar(&configPara.dbName, "d", "test", "Destination database.")
flag.StringVar(&configPara.tablePrefix, "m", "d", "Table prefix name.")
+ flag.StringVar(&configPara.mode, "M", "r", "mode,r:raw,s:stmt")
flag.IntVar(&configPara.numOftables, "t", 2, "The number of tables.")
flag.IntVar(&configPara.numOfRecordsPerTable, "n", 10, "The number of records per table.")
flag.IntVar(&configPara.numOfRecordsPerReq, "r", 3, "The number of records per request.")
@@ -94,6 +95,7 @@ func printAllArgs() {
fmt.Printf("usr: %v\n", configPara.user)
fmt.Printf("password: %v\n", configPara.password)
fmt.Printf("dbName: %v\n", configPara.dbName)
+ fmt.Printf("mode: %v\n", configPara.mode)
fmt.Printf("tablePrefix: %v\n", configPara.tablePrefix)
fmt.Printf("numOftables: %v\n", configPara.numOftables)
fmt.Printf("numOfRecordsPerTable: %v\n", configPara.numOfRecordsPerTable)
@@ -119,6 +121,24 @@ func main() {
//defer db.Close()
rand.Seed(time.Now().Unix())
+ if configPara.mode == "s" {
+ fmt.Printf("\n======== start stmt mode test ========\n")
+ db, err := sql.Open("taosSql", url)
+ if err != nil {
+ log.Fatalf("Open database error: %s\n", err)
+ }
+ defer db.Close()
+ demodbStmt := configPara.dbName
+ demotStmt := "demotStmt"
+ drop_database_stmt(db, demodbStmt)
+ create_database_stmt(db, demodbStmt)
+ use_database_stmt(db, demodbStmt)
+ create_table_stmt(db, demotStmt)
+ insert_data_stmt(db, demotStmt)
+ select_data_stmt(db, demotStmt)
+ return
+ }
+
createDatabase(configPara.dbName, configPara.supTblName)
fmt.Printf("======== create database success! ========\n\n")
@@ -407,6 +427,132 @@ func selectTest(dbName string, tbPrefix string, supTblName string) {
checkErr(err, "rows next iteration error")
}
}
+func drop_database_stmt(db *sql.DB, demodb string) {
+ st := time.Now().Nanosecond()
+ // drop test db
+ res, err := db.Exec("drop database if exists " + demodb)
+ checkErr(err, "drop database "+demodb)
+
+ affectd, err := res.RowsAffected()
+ checkErr(err, "drop db, res.RowsAffected")
+
+ et := time.Now().Nanosecond()
+ fmt.Printf("drop database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9)
+}
+
+func create_database_stmt(db *sql.DB, demodb string) {
+ st := time.Now().Nanosecond()
+ // create database
+ //var stmt interface{}
+ stmt, err := db.Prepare("create database ?")
+ checkErr(err, "create db, db.Prepare")
+
+ //var res driver.Result
+ res, err := stmt.Exec(demodb)
+ checkErr(err, "create db, stmt.Exec")
+
+ //fmt.Printf("Query OK, %d row(s) affected()", res.RowsAffected())
+ affectd, err := res.RowsAffected()
+ checkErr(err, "create db, res.RowsAffected")
+
+ et := time.Now().Nanosecond()
+ fmt.Printf("create database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9)
+}
+
+func use_database_stmt(db *sql.DB, demodb string) {
+ st := time.Now().Nanosecond()
+ // create database
+ //var stmt interface{}
+ stmt, err := db.Prepare("use " + demodb)
+ checkErr(err, "use db, db.Prepare")
+
+ res, err := stmt.Exec()
+ checkErr(err, "use db, stmt.Exec")
+
+ affectd, err := res.RowsAffected()
+ checkErr(err, "use db, res.RowsAffected")
+
+ et := time.Now().Nanosecond()
+ fmt.Printf("use database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9)
+}
+
+func create_table_stmt(db *sql.DB, demot string) {
+ st := time.Now().Nanosecond()
+ // create table
+ // (ts timestamp, id int, name binary(8), len tinyint, flag bool, notes binary(8), fv float, dv double)
+ stmt, err := db.Prepare("create table ? (? timestamp, ? int, ? binary(10), ? tinyint, ? bool, ? binary(8), ? float, ? double)")
+ checkErr(err, "create table db.Prepare")
+
+ res, err := stmt.Exec(demot, "ts", "id", "name", "len", "flag", "notes", "fv", "dv")
+ checkErr(err, "create table stmt.Exec")
+
+ affectd, err := res.RowsAffected()
+ checkErr(err, "create table res.RowsAffected")
+
+ et := time.Now().Nanosecond()
+ fmt.Printf("create table result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9)
+}
+
+func insert_data_stmt(db *sql.DB, demot string) {
+ st := time.Now().Nanosecond()
+ // insert data into table
+ stmt, err := db.Prepare("insert into ? values(?, ?, ?, ?, ?, ?, ?, ?) (?, ?, ?, ?, ?, ?, ?, ?) (?, ?, ?, ?, ?, ?, ?, ?)")
+ checkErr(err, "insert db.Prepare")
+
+ res, err := stmt.Exec(demot, "now", 1000, "'haidian'", 6, true, "'AI world'", 6987.654, 321.987,
+ "now+1s", 1001, "'changyang'", 7, false, "'DeepMode'", 12356.456, 128634.456,
+ "now+2s", 1002, "'chuangping'", 8, true, "'database'", 3879.456, 65433478.456)
+ checkErr(err, "insert data, stmt.Exec")
+
+ affectd, err := res.RowsAffected()
+ checkErr(err, "res.RowsAffected")
+
+ et := time.Now().Nanosecond()
+ fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9)
+}
+
+func select_data_stmt(db *sql.DB, demot string) {
+ st := time.Now().Nanosecond()
+
+ stmt, err := db.Prepare("select ?, ?, ?, ?, ?, ?, ?, ? from ?") // go binary mode
+ checkErr(err, "db.Prepare")
+
+ rows, err := stmt.Query("ts", "id", "name", "len", "flag", "notes", "fv", "dv", demot)
+ checkErr(err, "stmt.Query")
+
+ fmt.Printf("%10s%s%8s %5s %8s%s %s %10s%s %7s%s %8s%s %11s%s %14s%s\n", " ", "ts", " ", "id", " ", "name", " ", "len", " ", "flag", " ", "notes", " ", "fv", " ", " ", "dv")
+ var affectd int
+ for rows.Next() {
+ var ts string
+ var name string
+ var id int
+ var len int8
+ var flag bool
+ var notes string
+ var fv float32
+ var dv float64
+
+ err = rows.Scan(&ts, &id, &name, &len, &flag, ¬es, &fv, &dv)
+ //fmt.Println("start scan fields from row.rs, &fv:", &fv)
+ //err = rows.Scan(&fv)
+ checkErr(err, "rows.Scan")
+
+ fmt.Printf("%s\t", ts)
+ fmt.Printf("%d\t", id)
+ fmt.Printf("%10s\t", name)
+ fmt.Printf("%d\t", len)
+ fmt.Printf("%t\t", flag)
+ fmt.Printf("%s\t", notes)
+ fmt.Printf("%06.3f\t", fv)
+ fmt.Printf("%09.6f\n", dv)
+
+ affectd++
+
+ }
+
+ et := time.Now().Nanosecond()
+ fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9)
+}
func checkErr(err error, prompt string) {
if err != nil {
fmt.Printf("%s\n", prompt)
diff --git a/tests/perftest-scripts/perftest-query.sh b/tests/perftest-scripts/perftest-query.sh
index 0325f552b1..9a16084683 100755
--- a/tests/perftest-scripts/perftest-query.sh
+++ b/tests/perftest-scripts/perftest-query.sh
@@ -64,7 +64,7 @@ function runQueryPerfTest {
[ -f $PERFORMANCE_TEST_REPORT ] && rm $PERFORMANCE_TEST_REPORT
nohup $WORK_DIR/TDengine/debug/build/bin/taosd -c /etc/taosperf/ > /dev/null 2>&1 &
echoInfo "Wait TDengine to start"
- sleep 120
+ sleep 300
echoInfo "Run Performance Test"
cd $WORK_DIR/TDengine/tests/pytest
diff --git a/tests/pytest/alter/alterTabAddTagWithNULL.py b/tests/pytest/alter/alterTabAddTagWithNULL.py
new file mode 100644
index 0000000000..52bdc0fe75
--- /dev/null
+++ b/tests/pytest/alter/alterTabAddTagWithNULL.py
@@ -0,0 +1,85 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+from util.log import *
+from util.cases import *
+from util.sql import *
+from util.dnodes import *
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug(f"start to execute {__file__}")
+ tdSql.init(conn.cursor(), logSql)
+
+ def run(self):
+ tdSql.execute("drop database if exists db")
+ tdSql.execute("create database if not exists db keep 36500")
+ tdSql.execute("use db")
+
+ tdLog.printNoPrefix("==========step1:create table && insert data")
+ tdSql.execute("create table stbtag (ts timestamp, c1 int) TAGS(t1 int)")
+ tdSql.execute("create table tag1 using stbtag tags(1)")
+
+ tdLog.printNoPrefix("==========step2:alter stb add tag create new chiltable")
+ tdSql.execute("alter table stbtag add tag t2 int")
+ tdSql.execute("alter table stbtag add tag t3 tinyint")
+ tdSql.execute("alter table stbtag add tag t4 smallint ")
+ tdSql.execute("alter table stbtag add tag t5 bigint")
+ tdSql.execute("alter table stbtag add tag t6 float ")
+ tdSql.execute("alter table stbtag add tag t7 double ")
+ tdSql.execute("alter table stbtag add tag t8 bool ")
+ tdSql.execute("alter table stbtag add tag t9 binary(10) ")
+ tdSql.execute("alter table stbtag add tag t10 nchar(10)")
+
+ tdSql.execute("create table tag2 using stbtag tags(2, 22, 23, 24, 25, 26.1, 27.1, 1, 'binary9', 'nchar10')")
+ tdSql.query( "select tbname, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10 from stbtag" )
+ tdSql.checkData(1, 0, "tag2")
+ tdSql.checkData(1, 1, 2)
+ tdSql.checkData(1, 2, 22)
+ tdSql.checkData(1, 3, 23)
+ tdSql.checkData(1, 4, 24)
+ tdSql.checkData(1, 5, 25)
+ tdSql.checkData(1, 6, 26.1)
+ tdSql.checkData(1, 7, 27.1)
+ tdSql.checkData(1, 8, 1)
+ tdSql.checkData(1, 9, "binary9")
+ tdSql.checkData(1, 10, "nchar10")
+
+ tdLog.printNoPrefix("==========step3:alter stb drop tag create new chiltable")
+ tdSql.execute("alter table stbtag drop tag t2 ")
+ tdSql.execute("alter table stbtag drop tag t3 ")
+ tdSql.execute("alter table stbtag drop tag t4 ")
+ tdSql.execute("alter table stbtag drop tag t5 ")
+ tdSql.execute("alter table stbtag drop tag t6 ")
+ tdSql.execute("alter table stbtag drop tag t7 ")
+ tdSql.execute("alter table stbtag drop tag t8 ")
+ tdSql.execute("alter table stbtag drop tag t9 ")
+ tdSql.execute("alter table stbtag drop tag t10 ")
+
+ tdSql.execute("create table tag3 using stbtag tags(3)")
+ tdSql.query("select * from stbtag where tbname like 'tag3' ")
+ tdSql.checkCols(3)
+ tdSql.query("select tbname, t1 from stbtag where tbname like 'tag3' ")
+ tdSql.checkData(0, 1, 3)
+
+
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success(f"{__file__} successfully executed")
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
diff --git a/tests/pytest/alter/alterTimestampColDataProcess.py b/tests/pytest/alter/alterTimestampColDataProcess.py
new file mode 100644
index 0000000000..b235a8bf4c
--- /dev/null
+++ b/tests/pytest/alter/alterTimestampColDataProcess.py
@@ -0,0 +1,73 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+from util.log import *
+from util.cases import *
+from util.sql import *
+from util.dnodes import *
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug(f"start to execute {__file__}")
+ tdSql.init(conn.cursor(), logSql)
+
+ def run(self):
+ tdSql.execute("drop database if exists db")
+ tdSql.execute("create database if not exists db keep 36500")
+ tdSql.execute("use db")
+
+ tdLog.printNoPrefix("==========step1:create table && insert data")
+ # timestamp list:
+ # 0 -> "1970-01-01 08:00:00" | -28800000 -> "1970-01-01 00:00:00" | -946800000000 -> "1940-01-01 00:00:00"
+ # -631180800000 -> "1950-01-01 00:00:00"
+ ts1 = 0
+ ts2 = -28800000
+ ts3 = -946800000000
+ ts4 = "1950-01-01 00:00:00"
+ tdSql.execute(
+ "create table stb2ts (ts timestamp, ts1 timestamp, ts2 timestamp, c1 int, ts3 timestamp) TAGS(t1 int)"
+ )
+ tdSql.execute("create table t2ts1 using stb2ts tags(1)")
+
+ tdSql.execute(f"insert into t2ts1 values ({ts1}, {ts1}, {ts1}, 1, {ts1})")
+ tdSql.execute(f"insert into t2ts1 values ({ts2}, {ts2}, {ts2}, 2, {ts2})")
+ tdSql.execute(f"insert into t2ts1 values ({ts3}, {ts3}, {ts3}, 4, {ts3})")
+ tdSql.execute(f"insert into t2ts1 values ('{ts4}', '{ts4}', '{ts4}', 3, '{ts4}')")
+
+ tdLog.printNoPrefix("==========step2:check inserted data")
+ tdSql.query("select * from stb2ts where ts1=0 and ts2='1970-01-01 08:00:00' ")
+ tdSql.checkRows(1)
+ tdSql.checkData(0, 4,'1970-01-01 08:00:00')
+
+ tdSql.query("select * from stb2ts where ts1=-28800000 and ts2='1970-01-01 00:00:00' ")
+ tdSql.checkRows(1)
+ tdSql.checkData(0, 4, '1970-01-01 00:00:00')
+
+ tdSql.query("select * from stb2ts where ts1=-946800000000 and ts2='1940-01-01 00:00:00' ")
+ tdSql.checkRows(1)
+ tdSql.checkData(0, 4, '1940-01-01 00:00:00')
+
+ tdSql.query("select * from stb2ts where ts1=-631180800000 and ts2='1950-01-01 00:00:00' ")
+ tdSql.checkRows(1)
+ tdSql.checkData(0, 4, '1950-01-01 00:00:00')
+
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success(f"{__file__} successfully executed")
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh
index e7e0586636..86fbe2860d 100755
--- a/tests/pytest/fulltest.sh
+++ b/tests/pytest/fulltest.sh
@@ -219,6 +219,10 @@ python3 ./test.py -f query/bug3351.py
python3 ./test.py -f query/bug3375.py
python3 ./test.py -f query/queryJoin10tables.py
python3 ./test.py -f query/queryStddevWithGroupby.py
+python3 ./test.py -f query/querySecondtscolumnTowherenow.py
+python3 ./test.py -f query/queryFilterTswithDateUnit.py
+
+
#stream
python3 ./test.py -f stream/metric_1.py
@@ -234,6 +238,8 @@ python3 ./test.py -f stream/table_n.py
#alter table
python3 ./test.py -f alter/alter_table_crash.py
+python3 ./test.py -f alter/alterTabAddTagWithNULL.py
+python3 ./test.py -f alter/alterTimestampColDataProcess.py
# client
python3 ./test.py -f client/client.py
@@ -303,6 +309,11 @@ python3 ./test.py -f insert/unsignedSmallint.py
python3 ./test.py -f insert/unsignedTinyint.py
python3 ./test.py -f query/filterAllUnsignedIntTypes.py
+python3 ./test.py -f tag_lite/unsignedInt.py
+python3 ./test.py -f tag_lite/unsignedBigint.py
+python3 ./test.py -f tag_lite/unsignedSmallint.py
+python3 ./test.py -f tag_lite/unsignedTinyint.py
+
python3 ./test.py -f functions/function_percentile2.py
python3 ./test.py -f insert/boundary2.py
python3 ./test.py -f alter/alter_debugFlag.py
diff --git a/tests/pytest/query/queryFilterTswithDateUnit.py b/tests/pytest/query/queryFilterTswithDateUnit.py
new file mode 100644
index 0000000000..90e30c5156
--- /dev/null
+++ b/tests/pytest/query/queryFilterTswithDateUnit.py
@@ -0,0 +1,166 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+from util.log import *
+from util.cases import *
+from util.sql import *
+from util.dnodes import *
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug(f"start to execute {__file__}")
+ tdSql.init(conn.cursor(), logSql)
+
+ def insertnow(self, tsp1, tsp2, tsp3):
+
+ tdSql.execute(
+ "create table stbts (ts timestamp, ts1 timestamp, c1 int, ts2 timestamp) TAGS(t1 int)"
+ )
+ tdSql.execute("create table tts1 using stbts tags(1)")
+
+ tdSql.execute("insert into tts1 values (now+1d, now+1d, 6, now+1d)")
+ tdSql.execute("insert into tts1 values (now, now, 5, now)")
+ tdSql.execute("insert into tts1 values (now-1d, now-1d, 4, now-1d)")
+ tdSql.execute(f"insert into tts1 values ({tsp1}, {tsp1}, 3, {tsp1})")
+ tdSql.execute(f"insert into tts1 values ({tsp2}, {tsp2}, 2, {tsp2})")
+ tdSql.execute(f"insert into tts1 values ({tsp3}, {tsp3}, 1, {tsp3})")
+
+
+ def querynow(self):
+
+ tdLog.printNoPrefix("==========step query: execute query operation")
+ time.sleep(1)
+
+ cols = ["ts", "ts1", "ts2"]
+
+ for col in cols:
+ tdSql.error(f" select * from tts1 where {col} = 1d ")
+ tdSql.error(f" select * from tts1 where {col} < 1d ")
+ tdSql.error(f" select * from tts1 where {col} > 1d ")
+ tdSql.error(f" select * from tts1 where {col} >= 1d ")
+ tdSql.error(f" select * from tts1 where {col} <= 1d ")
+ tdSql.error(f" select * from tts1 where {col} <> 1d ")
+
+ tdSql.error(f" select * from tts1 where {col} = 1m ")
+ tdSql.error(f" select * from tts1 where {col} < 1m ")
+ tdSql.error(f" select * from tts1 where {col} > 1m ")
+ tdSql.error(f" select * from tts1 where {col} >= 1m ")
+ tdSql.error(f" select * from tts1 where {col} <= 1m ")
+ tdSql.error(f" select * from tts1 where {col} <> 1m ")
+
+ tdSql.error(f" select * from tts1 where {col} = 1s ")
+ tdSql.error(f" select * from tts1 where {col} < 1s ")
+ tdSql.error(f" select * from tts1 where {col} > 1s ")
+ tdSql.error(f" select * from tts1 where {col} >= 1s ")
+ tdSql.error(f" select * from tts1 where {col} <= 1s ")
+ tdSql.error(f" select * from tts1 where {col} <> 1s ")
+
+ tdSql.error(f" select * from tts1 where {col} = 1a ")
+ tdSql.error(f" select * from tts1 where {col} < 1a ")
+ tdSql.error(f" select * from tts1 where {col} > 1a ")
+ tdSql.error(f" select * from tts1 where {col} >= 1a ")
+ tdSql.error(f" select * from tts1 where {col} <= 1a ")
+ tdSql.error(f" select * from tts1 where {col} <> 1a ")
+
+ tdSql.error(f" select * from tts1 where {col} = 1h ")
+ tdSql.error(f" select * from tts1 where {col} < 1h ")
+ tdSql.error(f" select * from tts1 where {col} > 1h ")
+ tdSql.error(f" select * from tts1 where {col} >= 1h ")
+ tdSql.error(f" select * from tts1 where {col} <= 1h ")
+ tdSql.error(f" select * from tts1 where {col} <> 1h ")
+
+ tdSql.error(f" select * from tts1 where {col} = 1w ")
+ tdSql.error(f" select * from tts1 where {col} < 1w ")
+ tdSql.error(f" select * from tts1 where {col} > 1w ")
+ tdSql.error(f" select * from tts1 where {col} >= 1w ")
+ tdSql.error(f" select * from tts1 where {col} <= 1w ")
+ tdSql.error(f" select * from tts1 where {col} <> 1w ")
+
+ tdSql.error(f" select * from tts1 where {col} = 1u ")
+ tdSql.error(f" select * from tts1 where {col} < 1u ")
+ tdSql.error(f" select * from tts1 where {col} > 1u ")
+ tdSql.error(f" select * from tts1 where {col} >= 1u ")
+ tdSql.error(f" select * from tts1 where {col} <= 1u ")
+ tdSql.error(f" select * from tts1 where {col} <> 1u ")
+
+ tdSql.error(f" select * from tts1 where {col} = 0d ")
+ tdSql.error(f" select * from tts1 where {col} < 0s ")
+ tdSql.error(f" select * from tts1 where {col} > 0a ")
+ tdSql.error(f" select * from tts1 where {col} >= 0m ")
+ tdSql.error(f" select * from tts1 where {col} <= 0h ")
+ tdSql.error(f" select * from tts1 where {col} <> 0u ")
+ tdSql.error(f" select * from tts1 where {col} <> 0w ")
+
+ tdSql.error(f" select * from tts1 where {col} = 1m+1h ")
+ tdSql.error(f" select * from tts1 where {col} < 1w-1d ")
+ tdSql.error(f" select * from tts1 where {col} > 0a/1u ")
+ tdSql.error(f" select * from tts1 where {col} >= 1d/0s ")
+ tdSql.error(f" select * from tts1 where {col} <= 1s*1a ")
+ tdSql.error(f" select * from tts1 where {col} <> 0w/0d ")
+
+ tdSql.error(f" select * from tts1 where {col} = 1m+1h ")
+ tdSql.error(f" select * from tts1 where {col} < 1w-1d ")
+ tdSql.error(f" select * from tts1 where {col} > 0a/1u ")
+ tdSql.error(f" select * from tts1 where {col} >= 1d/0s ")
+ tdSql.error(f" select * from tts1 where {col} <= 1s*1a ")
+ tdSql.error(f" select * from tts1 where {col} <> 0w/0d ")
+
+ tdSql.error(f" select * from tts1 where {col} = 1u+1 ")
+ tdSql.error(f" select * from tts1 where {col} < 1a-1 ")
+ tdSql.error(f" select * from tts1 where {col} > 1s*1 ")
+ tdSql.error(f" select * from tts1 where {col} >= 1m/1 ")
+ tdSql.error(f" select * from tts1 where {col} <= 1h/0 ")
+ tdSql.error(f" select * from tts1 where {col} <> 0/1d ")
+ tdSql.error(f" select * from tts1 where {col} <> 1w+'2010-01-01 00:00:00' ")
+
+
+ def run(self):
+ tdSql.execute("drop database if exists dbms")
+ tdSql.execute("drop database if exists dbus")
+
+ # timestamp list:
+ # 0 -> "1970-01-01 08:00:00" | -28800000 -> "1970-01-01 00:00:00" | -946800000000 -> "1940-01-01 00:00:00"
+ # -631180800000 -> "1950-01-01 00:00:00"
+
+ tdLog.printNoPrefix("==========step1:create table precision ms && insert data && query")
+ # create databases precision is ms
+ tdSql.execute("create database if not exists dbms keep 36500")
+ tdSql.execute("use dbms")
+ tsp1 = 0
+ tsp2 = -28800000
+ tsp3 = -946800000000
+ self.insertnow(tsp1,tsp2,tsp3)
+ self.querynow()
+
+ tdLog.printNoPrefix("==========step2:create table precision us && insert data && query")
+ # create databases precision is us
+ tdSql.execute("create database if not exists dbus keep 36500 precision 'us' ")
+ tdSql.execute("use dbus")
+ tsp2 = -28800000 * 1000
+ tsp3 = -946800000000 * 1000
+ self.insertnow(tsp1,tsp2,tsp3)
+ self.querynow()
+
+
+
+
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success(f"{__file__} successfully executed")
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
diff --git a/tests/pytest/query/queryNormal.py b/tests/pytest/query/queryNormal.py
index 4e3f9dd3bd..52e49a57c6 100644
--- a/tests/pytest/query/queryNormal.py
+++ b/tests/pytest/query/queryNormal.py
@@ -16,7 +16,7 @@ import taos
from util.log import *
from util.cases import *
from util.sql import *
-
+from util.dnodes import *
class TDTestCase:
def init(self, conn, logSql):
@@ -122,6 +122,32 @@ class TDTestCase:
tdSql.query("SELECT server_status()")
tdSql.checkRows(1)
+ # https://jira.taosdata.com:18080/browse/TD-3800
+ tdSql.execute("create table m1(ts timestamp, k int) tags(a int)")
+ tdSql.execute("create table tm0 using m1 tags(1)")
+ tdSql.execute("create table tm1 using m1 tags(2)")
+ tdSql.execute("insert into tm0 values('2020-3-1 1:1:1', 112)")
+ tdSql.execute("insert into tm1 values('2020-1-1 1:1:1', 1)('2020-3-1 0:1:1', 421)")
+
+ tdSql.query("select last(*) from m1 group by tbname")
+ tdSql.checkData(0, 0, "2020-03-01 01:01:01")
+ tdSql.checkData(0, 1, 112)
+ tdSql.checkData(0, 2, "tm0")
+ tdSql.checkData(1, 0, "2020-03-01 00:01:01")
+ tdSql.checkData(1, 1, 421)
+ tdSql.checkData(1, 2, "tm1")
+
+ tdDnodes.stop(1)
+ tdDnodes.start(1)
+
+ tdSql.query("select last(*) from m1 group by tbname")
+ tdSql.checkData(0, 0, "2020-03-01 01:01:01")
+ tdSql.checkData(0, 1, 112)
+ tdSql.checkData(0, 2, "tm0")
+ tdSql.checkData(1, 0, "2020-03-01 00:01:01")
+ tdSql.checkData(1, 1, 421)
+ tdSql.checkData(1, 2, "tm1")
+
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
diff --git a/tests/pytest/query/querySecondtscolumnTowherenow.py b/tests/pytest/query/querySecondtscolumnTowherenow.py
new file mode 100644
index 0000000000..dfc18d99a6
--- /dev/null
+++ b/tests/pytest/query/querySecondtscolumnTowherenow.py
@@ -0,0 +1,131 @@
+###################################################################
+# Copyright (c) 2016 by TAOS Technologies, Inc.
+# All rights reserved.
+#
+# This file is proprietary and confidential to TAOS Technologies.
+# No part of this file may be reproduced, stored, transmitted,
+# disclosed or used in any form or by any means other than as
+# expressly provided by the written permission from Jianhui Tao
+#
+###################################################################
+
+# -*- coding: utf-8 -*-
+
+import sys
+from util.log import *
+from util.cases import *
+from util.sql import *
+from util.dnodes import *
+
+
+class TDTestCase:
+ def init(self, conn, logSql):
+ tdLog.debug(f"start to execute {__file__}")
+ tdSql.init(conn.cursor(), logSql)
+
+ def run(self):
+ tdSql.execute("drop database if exists db")
+ tdSql.execute("create database if not exists db keep 36500")
+ tdSql.execute("use db")
+
+ tdLog.printNoPrefix("==========step1:create table && insert data")
+ # timestamp list:
+ # 0->"1970-01-01 08:00:00" | -28800000->"1970-01-01 00:00:00" | -946800000000->"1940-01-01 00:00:00"
+ ts1 = 0
+ ts2 = -28800000
+ ts3 = -946800000000
+ tdSql.execute(
+ "create table stb2ts (ts timestamp, ts1 timestamp, ts2 timestamp, c1 int, ts3 timestamp) TAGS(t1 int)"
+ )
+ tdSql.execute("create table t2ts1 using stb2ts tags(1)")
+
+ tdSql.execute("insert into t2ts1 values (now, now, now, 1, now)")
+ tdSql.execute("insert into t2ts1 values (now-1m, now-1m, now-1m, 1, now-1m)")
+ tdSql.execute(f"insert into t2ts1 values ({ts1}, {ts1}, {ts1}, 1, {ts1})")
+ # tdSql.execute(f"insert into t2ts1 values ({ts2}, {ts2}, {ts2}, 1, {ts2})")
+ # tdSql.execute(f"insert into t2ts1 values ({ts3}, {ts3}, {ts3}, 1, {ts3})")
+
+ tdLog.printNoPrefix("==========step2:query")
+ time.sleep(1)
+ # query primary key timestamp column
+ tdSql.execute("select * from t2ts1 where ts < now")
+ ts_len1 = len(tdSql.cursor.fetchall())
+ tdSql.execute("select * from t2ts1 where ts <= now")
+ ts_len2 = len(tdSql.cursor.fetchall())
+ tdSql.execute("select * from t2ts1 where ts > now")
+ ts_len3 = len(tdSql.cursor.fetchall())
+ tdSql.execute("select * from t2ts1 where ts >= now")
+ ts_len4 = len(tdSql.cursor.fetchall())
+ tdSql.execute("select * from t2ts1 where ts = now")
+ ts_len5 = len(tdSql.cursor.fetchall())
+ tdSql.execute("select * from t2ts1 where ts <> now")
+ ts_len6 = len(tdSql.cursor.fetchall())
+ tdSql.execute("select * from t2ts1 where ts between 0 and now")
+ ts_len7 = len(tdSql.cursor.fetchall())
+ tdSql.execute("select * from t2ts1 where ts between now and now+100d")
+ ts_len8 = len(tdSql.cursor.fetchall())
+
+ # query noemal timestamp column
+ tdSql.query("select * from t2ts1 where ts1 < now")
+ tdSql.checkRows(ts_len1)
+ tdSql.query("select * from t2ts1 where ts2 < now")
+ tdSql.checkRows(ts_len1)
+ tdSql.query("select * from t2ts1 where ts3 < now")
+ tdSql.checkRows(ts_len1)
+
+ tdSql.query("select * from t2ts1 where ts1 <= now")
+ tdSql.checkRows(ts_len2)
+ tdSql.query("select * from t2ts1 where ts2 <= now")
+ tdSql.checkRows(ts_len2)
+ tdSql.query("select * from t2ts1 where ts3 <= now")
+ tdSql.checkRows(ts_len2)
+
+ tdSql.query("select * from t2ts1 where ts1 > now")
+ tdSql.checkRows(ts_len3)
+ tdSql.query("select * from t2ts1 where ts2 > now")
+ tdSql.checkRows(ts_len3)
+ tdSql.query("select * from t2ts1 where ts3 > now")
+ tdSql.checkRows(ts_len3)
+
+ tdSql.query("select * from t2ts1 where ts1 >= now")
+ tdSql.checkRows(ts_len4)
+ tdSql.query("select * from t2ts1 where ts2 >= now")
+ tdSql.checkRows(ts_len4)
+ tdSql.query("select * from t2ts1 where ts3 >= now")
+ tdSql.checkRows(ts_len4)
+
+ tdSql.query("select * from t2ts1 where ts1 = now")
+ tdSql.checkRows(ts_len5)
+ tdSql.query("select * from t2ts1 where ts2 = now")
+ tdSql.checkRows(ts_len5)
+ tdSql.query("select * from t2ts1 where ts2 = now")
+ tdSql.checkRows(ts_len5)
+
+ tdSql.query("select * from t2ts1 where ts1 <> now")
+ tdSql.checkRows(ts_len6)
+ tdSql.query("select * from t2ts1 where ts2 <> now")
+ tdSql.checkRows(ts_len6)
+ tdSql.query("select * from t2ts1 where ts3 <> now")
+ tdSql.checkRows(ts_len6)
+
+ tdSql.query("select * from t2ts1 where ts1 between 0 and now")
+ tdSql.checkRows(ts_len7)
+ tdSql.query("select * from t2ts1 where ts2 between 0 and now")
+ tdSql.checkRows(ts_len7)
+ tdSql.query("select * from t2ts1 where ts3 between 0 and now")
+ tdSql.checkRows(ts_len7)
+
+ tdSql.query("select * from t2ts1 where ts1 between now and now+100d")
+ tdSql.checkRows(ts_len8)
+ tdSql.query("select * from t2ts1 where ts2 between now and now+100d")
+ tdSql.checkRows(ts_len8)
+ tdSql.query("select * from t2ts1 where ts3 between now and now+100d")
+ tdSql.checkRows(ts_len8)
+
+ def stop(self):
+ tdSql.close()
+ tdLog.success(f"{__file__} successfully executed")
+
+
+tdCases.addWindows(__file__, TDTestCase())
+tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
diff --git a/tests/pytest/stream/new.py b/tests/pytest/stream/new.py
index 70f300e937..4a0e47c01a 100644
--- a/tests/pytest/stream/new.py
+++ b/tests/pytest/stream/new.py
@@ -42,7 +42,7 @@ class TDTestCase:
tdLog.info("=============== step3")
start = time.time()
- tdSql.waitedQuery("select * from st", 1, 120)
+ tdSql.waitedQuery("select * from st", 1, 180)
delay = int(time.time() - start) + 80
v = tdSql.getData(0, 3)
if v >= 51:
diff --git a/tests/pytest/stream/stream2.py b/tests/pytest/stream/stream2.py
index d71742048a..9b4eb8725c 100644
--- a/tests/pytest/stream/stream2.py
+++ b/tests/pytest/stream/stream2.py
@@ -88,6 +88,8 @@ class TDTestCase:
except Exception as e:
tdLog.info(repr(e))
+
+ time.sleep(5)
tdSql.query("show streams")
tdSql.checkRows(1)
tdSql.checkData(0, 2, 's0')
@@ -146,6 +148,7 @@ class TDTestCase:
except Exception as e:
tdLog.info(repr(e))
+ time.sleep(5)
tdSql.query("show streams")
tdSql.checkRows(2)
tdSql.checkData(0, 2, 's1')
diff --git a/tests/pytest/stream/sys.py b/tests/pytest/stream/sys.py
index a73e7043e8..c9a3fccfe6 100644
--- a/tests/pytest/stream/sys.py
+++ b/tests/pytest/stream/sys.py
@@ -47,7 +47,7 @@ class TDTestCase:
"select * from iostrm",
]
for sql in sqls:
- (rows, _) = tdSql.waitedQuery(sql, 1, 120)
+ (rows, _) = tdSql.waitedQuery(sql, 1, 240)
if rows < 1:
tdLog.exit("failed: sql:%s, expect at least one row" % sql)
diff --git a/tests/pytest/tools/taosdemoTestTblAlt.py b/tests/pytest/tools/taosdemoTestTblAlt.py
index bb367817cf..9aa131624e 100644
--- a/tests/pytest/tools/taosdemoTestTblAlt.py
+++ b/tests/pytest/tools/taosdemoTestTblAlt.py
@@ -100,8 +100,8 @@ class TDTestCase:
print("alter table test.meters add column col10 int")
tdSql.execute("alter table test.meters add column col10 int")
- print("insert into test.t9 values (now, 1, 2, 3, 4, 0.1, 0.01,'test', '测试', TRUE, 1610000000000, 0)")
- tdSql.execute("insert into test.t9 values (now, 1, 2, 3, 4, 0.1, 0.01,'test', '测试', TRUE, 1610000000000, 0)")
+ print("insert into test.t9 values (now, 1, 2, 3, 4, 0)")
+ tdSql.execute("insert into test.t9 values (now, 1, 2, 3, 4, 0)")
def run(self):
tdSql.prepare()
diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py
index 16931cca33..ba9cb4d53d 100644
--- a/tests/pytest/util/sql.py
+++ b/tests/pytest/util/sql.py
@@ -87,6 +87,7 @@ class TDSql:
self.queryResult = self.cursor.fetchall()
self.queryRows = len(self.queryResult)
self.queryCols = len(self.cursor.description)
+ tdLog.info("sql: %s, try to retrieve %d rows,get %d rows" % (sql, expectRows, self.queryRows))
if self.queryRows >= expectRows:
return (self.queryRows, i)
time.sleep(1)
@@ -105,6 +106,14 @@ class TDSql:
args = (caller.filename, caller.lineno, self.sql, self.queryRows, expectRows)
tdLog.exit("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args)
+ def checkCols(self, expectCols):
+ if self.queryCols == expectCols:
+ tdLog.info("sql:%s, queryCols:%d == expect:%d" % (self.sql, self.queryCols, expectCols))
+ else:
+ caller = inspect.getframeinfo(inspect.stack()[1][0])
+ args = (caller.filename, caller.lineno, self.sql, self.queryCols, expectCols)
+ tdLog.exit("%s(%d) failed: sql:%s, queryCols:%d != expect:%d" % args)
+
def checkRowCol(self, row, col):
caller = inspect.getframeinfo(inspect.stack()[2][0])
if row < 0:
diff --git a/tests/script/general/parser/first_last_query.sim b/tests/script/general/parser/first_last_query.sim
index 2d08759f3f..2dff1dd51b 100644
--- a/tests/script/general/parser/first_last_query.sim
+++ b/tests/script/general/parser/first_last_query.sim
@@ -269,4 +269,50 @@ if $data14 != @test2@ then
return -1
endi
-sql drop table stest
\ No newline at end of file
+sql drop table stest
+
+print ===================>td-3779
+sql create table m1(ts timestamp, k int) tags(a int);
+sql create table tm0 using m1 tags(1);
+sql create table tm1 using m1 tags(2);
+sql insert into tm0 values('2020-3-1 1:1:1', 112);
+sql insert into tm1 values('2020-1-1 1:1:1', 1)('2020-3-1 0:1:1', 421);
+system sh/exec.sh -n dnode1 -s stop -x SIGINT
+sleep 1000
+
+system sh/exec.sh -n dnode1 -s start
+print ================== server restart completed
+sleep 1000
+sql connect
+sql use first_db0;
+
+sql select last(*) from m1 group by tbname;
+if $rows != 2 then
+ return -1
+endi
+
+if $data00 != @20-03-01 01:01:01.000@ then
+ return -1
+endi
+
+if $data01 != 112 then
+ return -1
+endi
+
+if $data02 != @tm0@ then
+ return -1
+endi
+
+if $data10 != @20-03-01 00:01:01.000@ then
+ return -1
+endi
+
+if $data11 != 421 then
+ return -1
+endi
+
+if $data12 != @tm1@ then
+ return -1
+endi
+
+sql drop table m1
\ No newline at end of file
diff --git a/tests/script/general/parser/select_with_tags.sim b/tests/script/general/parser/select_with_tags.sim
index 9e9b921634..7e5f31f759 100644
--- a/tests/script/general/parser/select_with_tags.sim
+++ b/tests/script/general/parser/select_with_tags.sim
@@ -161,7 +161,7 @@ if $data03 != @abc15@ then
endi
sql select top(c6, 3) from select_tags_mt0 interval(10a)
-sql select top(c3,10) from select_tags_mt0 interval(10a) group by tbname
+sql select top(c3,10) from select_tags_mt0 interval(10a) group by tbname,t1,t2
sql select top(c6, 3) from select_tags_mt0 interval(10a) group by tbname;
sql select top(c6, 10) from select_tags_mt0 interval(10a);
diff --git a/tests/script/general/stream/stream_1970.sim b/tests/script/general/stream/stream_1970.sim
new file mode 100644
index 0000000000..30a733c08f
--- /dev/null
+++ b/tests/script/general/stream/stream_1970.sim
@@ -0,0 +1,73 @@
+system sh/stop_dnodes.sh
+
+system sh/deploy.sh -n dnode1 -i 1
+system sh/cfg.sh -n dnode1 -c walLevel -v 1
+system sh/exec.sh -n dnode1 -s start
+
+sleep 2000
+sql connect
+
+print ======================== dnode1 start
+
+$dbPrefix = s3_db
+$tbPrefix = s3_tb
+$mtPrefix = s3_mt
+$stPrefix = s3_st
+$tbNum = 10
+$rowNum = 20
+$totalNum = 200
+
+print =============== step1
+$i = 0
+$db = $dbPrefix . $i
+$mt = $mtPrefix . $i
+$st = $stPrefix . $i
+
+sql drop databae $db -x step1
+step1:
+sql create database $db keep 36500
+sql use $db
+sql create stable $mt (ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int)
+
+sql create table cq1 as select count(*) from $mt interval(10s);
+
+sleep 1000
+
+sql create table $st using $mt tags(1);
+
+sql insert into $st values (-50000, 1, 1.0);
+sql insert into $st values (-10000, 1, 1.0);
+sql insert into $st values (10000, 1, 1.0);
+
+
+$i = 0
+while $i < 12
+ sql select * from cq1;
+
+ if $rows != 3 then
+ sleep 10000
+ else
+ if $data00 != @70-01-01 07:59:10.000@ then
+ return -1
+ endi
+ if $data01 != 1 then
+ return -1
+ endi
+ if $data10 != @70-01-01 07:59:50.000@ then
+ return -1
+ endi
+ if $data11 != 1 then
+ return -1
+ endi
+ if $data20 != @70-01-01 08:00:10.000@ then
+ return -1
+ endi
+ if $data21 != 1 then
+ return -1
+ endi
+ $i = 12
+ endi
+
+ $i = $i + 1
+endw
+