提交 99706aff 编写于 作者: L lichuang

Merge branch 'develop' into fix/TD-5584

...@@ -10,7 +10,7 @@ ENDIF () ...@@ -10,7 +10,7 @@ ENDIF ()
IF (DEFINED VERCOMPATIBLE) IF (DEFINED VERCOMPATIBLE)
SET(TD_VER_COMPATIBLE ${VERCOMPATIBLE}) SET(TD_VER_COMPATIBLE ${VERCOMPATIBLE})
ELSE () ELSE ()
SET(TD_VER_COMPATIBLE "1.0.0.0") SET(TD_VER_COMPATIBLE "2.0.0.0")
ENDIF () ENDIF ()
find_program(HAVE_GIT NAMES git) find_program(HAVE_GIT NAMES git)
......
...@@ -54,6 +54,7 @@ if command -v sudo > /dev/null; then ...@@ -54,6 +54,7 @@ if command -v sudo > /dev/null; then
fi fi
update_flag=0 update_flag=0
prompt_force=0
initd_mod=0 initd_mod=0
service_mod=2 service_mod=2
...@@ -777,10 +778,21 @@ function is_version_compatible() { ...@@ -777,10 +778,21 @@ function is_version_compatible() {
if [ -f ${script_dir}/driver/vercomp.txt ]; then if [ -f ${script_dir}/driver/vercomp.txt ]; then
min_compatible_version=`cat ${script_dir}/driver/vercomp.txt` min_compatible_version=`cat ${script_dir}/driver/vercomp.txt`
else else
min_compatible_version=$(${script_dir}/bin/tqd -V | head -1 | cut -d ' ' -f 5) min_compatible_version=$(${script_dir}/bin/taosd -V | head -1 | cut -d ' ' -f 5)
fi fi
# [TD-5628] prompt to execute taosd --force-keep-file if upgrade from lower version within 2.0.16.0
exist_version=$(/usr/local/taos/bin/taosd -V | head -1 | cut -d ' ' -f 3)
vercomp $exist_version "2.0.16.0"
case $? in
2)
prompt_force=1
;;
esac
vercomp $curr_version $min_compatible_version vercomp $curr_version $min_compatible_version
echo "" # avoid $? value not update
case $? in case $? in
0) return 0;; 0) return 0;;
1) return 0;; 1) return 0;;
...@@ -789,6 +801,12 @@ function is_version_compatible() { ...@@ -789,6 +801,12 @@ function is_version_compatible() {
} }
function update_TDengine() { function update_TDengine() {
# Check if version compatible
if ! is_version_compatible; then
echo -e "${RED}Version incompatible${NC}"
return 1
fi
# Start to update # Start to update
if [ ! -e taos.tar.gz ]; then if [ ! -e taos.tar.gz ]; then
echo "File taos.tar.gz does not exist" echo "File taos.tar.gz does not exist"
...@@ -797,12 +815,6 @@ function update_TDengine() { ...@@ -797,12 +815,6 @@ function update_TDengine() {
tar -zxf taos.tar.gz tar -zxf taos.tar.gz
install_jemalloc install_jemalloc
# Check if version compatible
if ! is_version_compatible; then
echo -e "${RED}Version incompatible${NC}"
return 1
fi
echo -e "${GREEN}Start to update TDengine...${NC}" echo -e "${GREEN}Start to update TDengine...${NC}"
# Stop the service if running # Stop the service if running
if pidof taosd &> /dev/null; then if pidof taosd &> /dev/null; then
...@@ -875,6 +887,10 @@ function update_TDengine() { ...@@ -875,6 +887,10 @@ function update_TDengine() {
echo -e "${GREEN_DARK}To access TDengine ${NC}: use ${GREEN_UNDERLINE}taos -h $serverFqdn${NC} in shell${NC}" echo -e "${GREEN_DARK}To access TDengine ${NC}: use ${GREEN_UNDERLINE}taos -h $serverFqdn${NC} in shell${NC}"
fi fi
if ((${prompt_force}==1)); then
echo ""
echo -e "${RED}Please run 'taosd --force-keep-file' at first time for the exist TDengine $exist_version!${NC}"
fi
echo echo
echo -e "\033[44;32;1mTDengine is updated successfully!${NC}" echo -e "\033[44;32;1mTDengine is updated successfully!${NC}"
else else
......
...@@ -746,7 +746,7 @@ function is_version_compatible() { ...@@ -746,7 +746,7 @@ function is_version_compatible() {
if [ -f ${script_dir}/driver/vercomp.txt ]; then if [ -f ${script_dir}/driver/vercomp.txt ]; then
min_compatible_version=`cat ${script_dir}/driver/vercomp.txt` min_compatible_version=`cat ${script_dir}/driver/vercomp.txt`
else else
min_compatible_version=$(${script_dir}/bin/tqd -V | head -1 | cut -d ' ' -f 5) min_compatible_version=$(${script_dir}/bin/powerd -V | head -1 | cut -d ' ' -f 5)
fi fi
vercomp $curr_version $min_compatible_version vercomp $curr_version $min_compatible_version
......
...@@ -726,12 +726,12 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_prepareStmtImp(J ...@@ -726,12 +726,12 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_prepareStmtImp(J
TAOS_STMT* pStmt = taos_stmt_init(tscon); TAOS_STMT* pStmt = taos_stmt_init(tscon);
int32_t code = taos_stmt_prepare(pStmt, str, len); int32_t code = taos_stmt_prepare(pStmt, str, len);
tfree(str);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
jniError("jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code)); jniError("jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code));
return JNI_TDENGINE_ERROR; return JNI_TDENGINE_ERROR;
} }
free(str);
return (jlong) pStmt; return (jlong) pStmt;
} }
...@@ -937,13 +937,13 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setTableNameTagsI ...@@ -937,13 +937,13 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setTableNameTagsI
tfree(lengthArray); tfree(lengthArray);
tfree(typeArray); tfree(typeArray);
tfree(nullArray); tfree(nullArray);
tfree(tagsBind);
(*env)->ReleaseStringUTFChars(env, tableName, name); (*env)->ReleaseStringUTFChars(env, tableName, name);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
jniError("jobj:%p, conn:%p, code:%s", jobj, tsconn, tstrerror(code)); jniError("jobj:%p, conn:%p, code:%s", jobj, tsconn, tstrerror(code));
return JNI_TDENGINE_ERROR; return JNI_TDENGINE_ERROR;
} }
return JNI_SUCCESS; return JNI_SUCCESS;
} }
...@@ -957,7 +957,10 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J ...@@ -957,7 +957,10 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J
int numLines = (*env)->GetArrayLength(env, lines); int numLines = (*env)->GetArrayLength(env, lines);
char** c_lines = calloc(numLines, sizeof(char*)); char** c_lines = calloc(numLines, sizeof(char*));
if (c_lines == NULL) {
jniError("c_lines:%p, alloc memory failed", c_lines);
return JNI_OUT_OF_MEMORY;
}
for (int i = 0; i < numLines; ++i) { for (int i = 0; i < numLines; ++i) {
jstring line = (jstring) ((*env)->GetObjectArrayElement(env, lines, i)); jstring line = (jstring) ((*env)->GetObjectArrayElement(env, lines, i));
c_lines[i] = (char*)(*env)->GetStringUTFChars(env, line, 0); c_lines[i] = (char*)(*env)->GetStringUTFChars(env, line, 0);
...@@ -970,10 +973,11 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J ...@@ -970,10 +973,11 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J
(*env)->ReleaseStringUTFChars(env, line, c_lines[i]); (*env)->ReleaseStringUTFChars(env, line, c_lines[i]);
} }
tfree(c_lines);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
jniError("jobj:%p, conn:%p, code:%s", jobj, taos, tstrerror(code)); jniError("jobj:%p, conn:%p, code:%s", jobj, taos, tstrerror(code));
return JNI_TDENGINE_ERROR; return JNI_TDENGINE_ERROR;
} }
return code; return code;
} }
\ No newline at end of file
...@@ -211,27 +211,27 @@ void taos_fetch_rows_a(TAOS_RES *tres, __async_cb_func_t fp, void *param) { ...@@ -211,27 +211,27 @@ void taos_fetch_rows_a(TAOS_RES *tres, __async_cb_func_t fp, void *param) {
pSql->fp = tscAsyncFetchRowsProxy; pSql->fp = tscAsyncFetchRowsProxy;
pSql->param = param; pSql->param = param;
if (pRes->qId == 0) {
tscError("qhandle is invalid");
pRes->code = TSDB_CODE_TSC_INVALID_QHANDLE;
tscAsyncResultOnError(pSql);
return;
}
tscResetForNextRetrieve(pRes); tscResetForNextRetrieve(pRes);
// handle outer query based on the already retrieved nest query results. // handle outer query based on the already retrieved nest query results.
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd); SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd);
if (pQueryInfo->pUpstream != NULL && taosArrayGetSize(pQueryInfo->pUpstream) > 0) { if (pQueryInfo->pUpstream != NULL && taosArrayGetSize(pQueryInfo->pUpstream) > 0) {
SSchedMsg schedMsg = {0}; SSchedMsg schedMsg = {0};
schedMsg.fp = doRetrieveSubqueryData; schedMsg.fp = doRetrieveSubqueryData;
schedMsg.ahandle = (void *)pSql; schedMsg.ahandle = (void *)pSql;
schedMsg.thandle = (void *)1; schedMsg.thandle = (void *)1;
schedMsg.msg = 0; schedMsg.msg = 0;
taosScheduleTask(tscQhandle, &schedMsg); taosScheduleTask(tscQhandle, &schedMsg);
return; return;
} }
if (pRes->qId == 0) {
tscError("qhandle is invalid");
pRes->code = TSDB_CODE_TSC_INVALID_QHANDLE;
tscAsyncResultOnError(pSql);
return;
}
if (pCmd->command == TSDB_SQL_TABLE_JOIN_RETRIEVE) { if (pCmd->command == TSDB_SQL_TABLE_JOIN_RETRIEVE) {
tscFetchDatablockForSubquery(pSql); tscFetchDatablockForSubquery(pSql);
} else if (pRes->completed) { } else if (pRes->completed) {
...@@ -409,9 +409,6 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { ...@@ -409,9 +409,6 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
return; return;
} }
taosReleaseRef(tscObjRef, pSql->self);
return;
_error: _error:
pRes->code = code; pRes->code = code;
tscAsyncResultOnError(pSql); tscAsyncResultOnError(pSql);
......
...@@ -135,7 +135,7 @@ int32_t tscCreateGlobalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, t ...@@ -135,7 +135,7 @@ int32_t tscCreateGlobalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, t
SLocalDataSource *ds = (SLocalDataSource *)malloc(sizeof(SLocalDataSource) + pMemBuffer[0]->pageSize); SLocalDataSource *ds = (SLocalDataSource *)malloc(sizeof(SLocalDataSource) + pMemBuffer[0]->pageSize);
if (ds == NULL) { if (ds == NULL) {
tscError("0x%"PRIx64" failed to create merge structure", id); tscError("0x%"PRIx64" failed to create merge structure", id);
tfree(pMerger); tfree(*pMerger);
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
...@@ -444,6 +444,9 @@ int32_t tscCreateGlobalMergerEnv(SQueryInfo *pQueryInfo, tExtMemBuffer ***pMemBu ...@@ -444,6 +444,9 @@ int32_t tscCreateGlobalMergerEnv(SQueryInfo *pQueryInfo, tExtMemBuffer ***pMemBu
pModel = createColumnModel(pSchema, (int32_t)size, capacity); pModel = createColumnModel(pSchema, (int32_t)size, capacity);
tfree(pSchema); tfree(pSchema);
if (pModel == NULL){
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
int32_t pg = DEFAULT_PAGE_SIZE; int32_t pg = DEFAULT_PAGE_SIZE;
int32_t overhead = sizeof(tFilePage); int32_t overhead = sizeof(tFilePage);
...@@ -458,6 +461,7 @@ int32_t tscCreateGlobalMergerEnv(SQueryInfo *pQueryInfo, tExtMemBuffer ***pMemBu ...@@ -458,6 +461,7 @@ int32_t tscCreateGlobalMergerEnv(SQueryInfo *pQueryInfo, tExtMemBuffer ***pMemBu
} }
if (createOrderDescriptor(pOrderDesc, pQueryInfo, pModel) != TSDB_CODE_SUCCESS) { if (createOrderDescriptor(pOrderDesc, pQueryInfo, pModel) != TSDB_CODE_SUCCESS) {
tfree(pModel);
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
......
...@@ -851,14 +851,18 @@ static int32_t tscProcessServStatus(SSqlObj *pSql) { ...@@ -851,14 +851,18 @@ static int32_t tscProcessServStatus(SSqlObj *pSql) {
SSqlObj* pHb = (SSqlObj*)taosAcquireRef(tscObjRef, pObj->hbrid); SSqlObj* pHb = (SSqlObj*)taosAcquireRef(tscObjRef, pObj->hbrid);
if (pHb != NULL) { if (pHb != NULL) {
pSql->res.code = pHb->res.code; pSql->res.code = pHb->res.code;
taosReleaseRef(tscObjRef, pObj->hbrid);
} }
if (pSql->res.code == TSDB_CODE_RPC_NETWORK_UNAVAIL) { if (pSql->res.code == TSDB_CODE_RPC_NETWORK_UNAVAIL) {
taosReleaseRef(tscObjRef, pObj->hbrid);
return pSql->res.code; return pSql->res.code;
} }
pSql->res.code = checkForOnlineNode(pHb); if (pHb != NULL) {
pSql->res.code = checkForOnlineNode(pHb);
taosReleaseRef(tscObjRef, pObj->hbrid);
}
if (pSql->res.code == TSDB_CODE_RPC_NETWORK_UNAVAIL) { if (pSql->res.code == TSDB_CODE_RPC_NETWORK_UNAVAIL) {
return pSql->res.code; return pSql->res.code;
} }
......
...@@ -2105,7 +2105,7 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int32_t numOfRow ...@@ -2105,7 +2105,7 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int32_t numOfRow
pParentSql->fp = pParentSql->fetchFp; pParentSql->fp = pParentSql->fetchFp;
// all data has been sent to vnode, call user function // all data has been sent to vnode, call user function
int32_t v = (code != TSDB_CODE_SUCCESS) ? code : (int32_t)pParentSql->res.numOfRows; int32_t v = (int32_t)pParentSql->res.numOfRows;
(*pParentSql->fp)(pParentSql->param, pParentSql, v); (*pParentSql->fp)(pParentSql->param, pParentSql, v);
return; return;
} }
......
...@@ -424,6 +424,11 @@ int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema, SSm ...@@ -424,6 +424,11 @@ int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema, SSm
taos_free_result(res); taos_free_result(res);
SSqlObj* pSql = calloc(1, sizeof(SSqlObj)); SSqlObj* pSql = calloc(1, sizeof(SSqlObj));
if (pSql == NULL){
tscError("failed to allocate memory, reason:%s", strerror(errno));
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
return code;
}
pSql->pTscObj = taos; pSql->pTscObj = taos;
pSql->signature = pSql; pSql->signature = pSql;
pSql->fp = NULL; pSql->fp = NULL;
...@@ -434,20 +439,18 @@ int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema, SSm ...@@ -434,20 +439,18 @@ int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema, SSm
if (tscValidateName(&tableToken) != TSDB_CODE_SUCCESS) { if (tscValidateName(&tableToken) != TSDB_CODE_SUCCESS) {
code = TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH; code = TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH;
sprintf(pSql->cmd.payload, "table name is invalid"); sprintf(pSql->cmd.payload, "table name is invalid");
tscFreeSqlObj(pSql);
return code; return code;
} }
SName sname = {0}; SName sname = {0};
if ((code = tscSetTableFullName(&sname, &tableToken, pSql)) != TSDB_CODE_SUCCESS) { if ((code = tscSetTableFullName(&sname, &tableToken, pSql)) != TSDB_CODE_SUCCESS) {
tscFreeSqlObj(pSql);
return code; return code;
} }
char fullTableName[TSDB_TABLE_FNAME_LEN] = {0}; char fullTableName[TSDB_TABLE_FNAME_LEN] = {0};
memset(fullTableName, 0, tListLen(fullTableName)); memset(fullTableName, 0, tListLen(fullTableName));
tNameExtractFullName(&sname, fullTableName); tNameExtractFullName(&sname, fullTableName);
if (code != TSDB_CODE_SUCCESS) {
tscFreeSqlObj(pSql);
return code;
}
tscFreeSqlObj(pSql); tscFreeSqlObj(pSql);
schema->tags = taosArrayInit(8, sizeof(SSchema)); schema->tags = taosArrayInit(8, sizeof(SSchema));
...@@ -636,6 +639,10 @@ static int32_t creatChildTableIfNotExists(TAOS* taos, const char* cTableName, co ...@@ -636,6 +639,10 @@ static int32_t creatChildTableIfNotExists(TAOS* taos, const char* cTableName, co
SArray* tagsSchema, SArray* tagsBind, SSmlLinesInfo* info) { SArray* tagsSchema, SArray* tagsBind, SSmlLinesInfo* info) {
size_t numTags = taosArrayGetSize(tagsSchema); size_t numTags = taosArrayGetSize(tagsSchema);
char* sql = malloc(tsMaxSQLStringLen+1); char* sql = malloc(tsMaxSQLStringLen+1);
if (sql == NULL) {
tscError("malloc sql memory error");
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
int freeBytes = tsMaxSQLStringLen + 1; int freeBytes = tsMaxSQLStringLen + 1;
sprintf(sql, "create table if not exists %s using %s", cTableName, sTableName); sprintf(sql, "create table if not exists %s using %s", cTableName, sTableName);
...@@ -657,23 +664,30 @@ static int32_t creatChildTableIfNotExists(TAOS* taos, const char* cTableName, co ...@@ -657,23 +664,30 @@ static int32_t creatChildTableIfNotExists(TAOS* taos, const char* cTableName, co
tscDebug("SML:0x%"PRIx64" create table : %s", info->id, sql); tscDebug("SML:0x%"PRIx64" create table : %s", info->id, sql);
TAOS_STMT* stmt = taos_stmt_init(taos); TAOS_STMT* stmt = taos_stmt_init(taos);
if (stmt == NULL) {
free(sql);
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
int32_t code; int32_t code;
code = taos_stmt_prepare(stmt, sql, (unsigned long)strlen(sql)); code = taos_stmt_prepare(stmt, sql, (unsigned long)strlen(sql));
free(sql); free(sql);
if (code != 0) { if (code != 0) {
tfree(stmt);
tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt)); tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt));
return code; return code;
} }
code = taos_stmt_bind_param(stmt, TARRAY_GET_START(tagsBind)); code = taos_stmt_bind_param(stmt, TARRAY_GET_START(tagsBind));
if (code != 0) { if (code != 0) {
tfree(stmt);
tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt)); tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt));
return code; return code;
} }
code = taos_stmt_execute(stmt); code = taos_stmt_execute(stmt);
if (code != 0) { if (code != 0) {
tfree(stmt);
tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt)); tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt));
return code; return code;
} }
...@@ -689,6 +703,11 @@ static int32_t creatChildTableIfNotExists(TAOS* taos, const char* cTableName, co ...@@ -689,6 +703,11 @@ static int32_t creatChildTableIfNotExists(TAOS* taos, const char* cTableName, co
static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* colsSchema, SArray* rowsBind, SSmlLinesInfo* info) { static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* colsSchema, SArray* rowsBind, SSmlLinesInfo* info) {
size_t numCols = taosArrayGetSize(colsSchema); size_t numCols = taosArrayGetSize(colsSchema);
char* sql = malloc(tsMaxSQLStringLen+1); char* sql = malloc(tsMaxSQLStringLen+1);
if (sql == NULL) {
tscError("malloc sql memory error");
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
int32_t freeBytes = tsMaxSQLStringLen + 1 ; int32_t freeBytes = tsMaxSQLStringLen + 1 ;
sprintf(sql, "insert into ? ("); sprintf(sql, "insert into ? (");
...@@ -710,11 +729,15 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols ...@@ -710,11 +729,15 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols
int32_t try = 0; int32_t try = 0;
TAOS_STMT* stmt = taos_stmt_init(taos); TAOS_STMT* stmt = taos_stmt_init(taos);
if (stmt == NULL) {
tfree(sql);
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
code = taos_stmt_prepare(stmt, sql, (unsigned long)strlen(sql)); code = taos_stmt_prepare(stmt, sql, (unsigned long)strlen(sql));
free(sql); tfree(sql);
if (code != 0) { if (code != 0) {
tfree(stmt);
tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt)); tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt));
return code; return code;
} }
...@@ -722,6 +745,7 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols ...@@ -722,6 +745,7 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols
do { do {
code = taos_stmt_set_tbname(stmt, cTableName); code = taos_stmt_set_tbname(stmt, cTableName);
if (code != 0) { if (code != 0) {
tfree(stmt);
tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt)); tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt));
return code; return code;
} }
...@@ -731,11 +755,13 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols ...@@ -731,11 +755,13 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols
TAOS_BIND* colsBinds = taosArrayGetP(rowsBind, i); TAOS_BIND* colsBinds = taosArrayGetP(rowsBind, i);
code = taos_stmt_bind_param(stmt, colsBinds); code = taos_stmt_bind_param(stmt, colsBinds);
if (code != 0) { if (code != 0) {
tfree(stmt);
tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt)); tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt));
return code; return code;
} }
code = taos_stmt_add_batch(stmt); code = taos_stmt_add_batch(stmt);
if (code != 0) { if (code != 0) {
tfree(stmt);
tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt)); tscError("SML:0x%"PRIx64" %s", info->id, taos_stmt_errstr(stmt));
return code; return code;
} }
...@@ -1757,7 +1783,7 @@ static bool checkDuplicateKey(char *key, SHashObj *pHash) { ...@@ -1757,7 +1783,7 @@ static bool checkDuplicateKey(char *key, SHashObj *pHash) {
static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash) { static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash) {
const char *cur = *index; const char *cur = *index;
char key[TSDB_COL_NAME_LEN]; char key[TSDB_COL_NAME_LEN + 1]; // +1 to avoid key[len] over write
uint16_t len = 0; uint16_t len = 0;
//key field cannot start with digit //key field cannot start with digit
...@@ -1839,7 +1865,10 @@ static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index ...@@ -1839,7 +1865,10 @@ static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index
const char *cur = *index; const char *cur = *index;
uint16_t len = 0; uint16_t len = 0;
pSml->stableName = calloc(TSDB_TABLE_NAME_LEN, 1); pSml->stableName = calloc(TSDB_TABLE_NAME_LEN + 1, 1); // +1 to avoid 1772 line over write
if (pSml->stableName == NULL){
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
if (isdigit(*cur)) { if (isdigit(*cur)) {
tscError("Measurement field cannnot start with digit"); tscError("Measurement field cannnot start with digit");
free(pSml->stableName); free(pSml->stableName);
......
...@@ -1628,8 +1628,8 @@ int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags ...@@ -1628,8 +1628,8 @@ int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags
if (pStmt->mtb.subSet && taosHashGetSize(pStmt->mtb.pTableHash) > 0) { if (pStmt->mtb.subSet && taosHashGetSize(pStmt->mtb.pTableHash) > 0) {
STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, 0); STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, 0);
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
char sTableName[TSDB_TABLE_FNAME_LEN]; char sTableName[TSDB_TABLE_FNAME_LEN] = {0};
strncpy(sTableName, pTableMeta->sTableName, sizeof(sTableName)); tstrncpy(sTableName, pTableMeta->sTableName, sizeof(sTableName));
SStrToken tname = {0}; SStrToken tname = {0};
tname.type = TK_STRING; tname.type = TK_STRING;
...@@ -1773,7 +1773,9 @@ int taos_stmt_close(TAOS_STMT* stmt) { ...@@ -1773,7 +1773,9 @@ int taos_stmt_close(TAOS_STMT* stmt) {
} }
tscDestroyDataBlock(pStmt->mtb.lastBlock, rmMeta); tscDestroyDataBlock(pStmt->mtb.lastBlock, rmMeta);
pStmt->mtb.pTableBlockHashList = tscDestroyBlockHashTable(pStmt->mtb.pTableBlockHashList, rmMeta); pStmt->mtb.pTableBlockHashList = tscDestroyBlockHashTable(pStmt->mtb.pTableBlockHashList, rmMeta);
taosHashCleanup(pStmt->pSql->cmd.insertParam.pTableBlockHashList); if (pStmt->pSql){
taosHashCleanup(pStmt->pSql->cmd.insertParam.pTableBlockHashList);
}
pStmt->pSql->cmd.insertParam.pTableBlockHashList = NULL; pStmt->pSql->cmd.insertParam.pTableBlockHashList = NULL;
taosArrayDestroy(pStmt->mtb.tags); taosArrayDestroy(pStmt->mtb.tags);
tfree(pStmt->mtb.sqlstr); tfree(pStmt->mtb.sqlstr);
......
...@@ -421,7 +421,8 @@ int32_t readFromFile(char *name, uint32_t *len, void **buf) { ...@@ -421,7 +421,8 @@ int32_t readFromFile(char *name, uint32_t *len, void **buf) {
tfree(*buf); tfree(*buf);
return TSDB_CODE_TSC_APP_ERROR; return TSDB_CODE_TSC_APP_ERROR;
} }
close(fd);
tfree(*buf);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -898,8 +899,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -898,8 +899,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
for (int32_t i = 0; i < size; ++i) { for (int32_t i = 0; i < size; ++i) {
SSqlNode* pSqlNode = taosArrayGetP(pInfo->list, i); SSqlNode* pSqlNode = taosArrayGetP(pInfo->list, i);
tscTrace("%p start to parse %dth subclause, total:%"PRIzu, pSql, i, size); tscTrace("0x%"PRIx64" start to parse the %dth subclause, total:%"PRIzu, pSql->self, i, size);
// normalizeSqlNode(pSqlNode); // normalize the column name in each function // normalizeSqlNode(pSqlNode); // normalize the column name in each function
if ((code = validateSqlNode(pSql, pSqlNode, pQueryInfo)) != TSDB_CODE_SUCCESS) { if ((code = validateSqlNode(pSql, pSqlNode, pQueryInfo)) != TSDB_CODE_SUCCESS) {
return code; return code;
...@@ -6869,7 +6869,8 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo ...@@ -6869,7 +6869,8 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo
tagSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta); tagSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta);
} }
SSchema* s = NULL; SSchema tmp = {.type = 0, .name = "", .colId = 0, .bytes = 0};
SSchema* s = &tmp;
for (int32_t i = 0; i < pQueryInfo->groupbyExpr.numOfGroupCols; ++i) { for (int32_t i = 0; i < pQueryInfo->groupbyExpr.numOfGroupCols; ++i) {
SColIndex* pColIndex = taosArrayGet(pQueryInfo->groupbyExpr.columnInfo, i); SColIndex* pColIndex = taosArrayGet(pQueryInfo->groupbyExpr.columnInfo, i);
...@@ -6879,7 +6880,9 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo ...@@ -6879,7 +6880,9 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo
s = tGetTbnameColumnSchema(); s = tGetTbnameColumnSchema();
} else { } else {
if (TSDB_COL_IS_TAG(pColIndex->flag)) { if (TSDB_COL_IS_TAG(pColIndex->flag)) {
s = &tagSchema[colIndex]; if(tagSchema){
s = &tagSchema[colIndex];
}
} else { } else {
s = &pSchema[colIndex]; s = &pSchema[colIndex];
} }
...@@ -8120,7 +8123,8 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -8120,7 +8123,8 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
assert(maxSize < 80 * TSDB_MAX_COLUMNS); assert(maxSize < 80 * TSDB_MAX_COLUMNS);
if (!pSql->pBuf) { if (!pSql->pBuf) {
if (NULL == (pSql->pBuf = tcalloc(1, 80 * TSDB_MAX_COLUMNS))) { if (NULL == (pSql->pBuf = tcalloc(1, 80 * TSDB_MAX_COLUMNS))) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; code = TSDB_CODE_TSC_OUT_OF_MEMORY;
goto _end;
} }
} }
...@@ -8399,14 +8403,18 @@ static int32_t doValidateSubquery(SSqlNode* pSqlNode, int32_t index, SSqlObj* pS ...@@ -8399,14 +8403,18 @@ static int32_t doValidateSubquery(SSqlNode* pSqlNode, int32_t index, SSqlObj* pS
// create dummy table meta info // create dummy table meta info
STableMetaInfo* pTableMetaInfo1 = calloc(1, sizeof(STableMetaInfo)); STableMetaInfo* pTableMetaInfo1 = calloc(1, sizeof(STableMetaInfo));
if (pTableMetaInfo1 == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
pTableMetaInfo1->pTableMeta = extractTempTableMetaFromSubquery(pSub); pTableMetaInfo1->pTableMeta = extractTempTableMetaFromSubquery(pSub);
if (subInfo->aliasName.n > 0) { if (subInfo->aliasName.n > 0) {
if (subInfo->aliasName.n >= TSDB_TABLE_FNAME_LEN) { if (subInfo->aliasName.n >= TSDB_TABLE_FNAME_LEN) {
tfree(pTableMetaInfo1);
return invalidOperationMsg(msgBuf, "subquery alias name too long"); return invalidOperationMsg(msgBuf, "subquery alias name too long");
} }
strncpy(pTableMetaInfo1->aliasName, subInfo->aliasName.z, subInfo->aliasName.n); tstrncpy(pTableMetaInfo1->aliasName, subInfo->aliasName.z, subInfo->aliasName.n + 1);
} }
taosArrayPush(pQueryInfo->pUpstream, &pSub); taosArrayPush(pQueryInfo->pUpstream, &pSub);
...@@ -8416,6 +8424,7 @@ static int32_t doValidateSubquery(SSqlNode* pSqlNode, int32_t index, SSqlObj* pS ...@@ -8416,6 +8424,7 @@ static int32_t doValidateSubquery(SSqlNode* pSqlNode, int32_t index, SSqlObj* pS
STableMetaInfo** tmp = realloc(pQueryInfo->pTableMetaInfo, (pQueryInfo->numOfTables + 1) * POINTER_BYTES); STableMetaInfo** tmp = realloc(pQueryInfo->pTableMetaInfo, (pQueryInfo->numOfTables + 1) * POINTER_BYTES);
if (tmp == NULL) { if (tmp == NULL) {
tfree(pTableMetaInfo1);
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
......
...@@ -164,7 +164,7 @@ static void tscUpdateVgroupInfo(SSqlObj *pSql, SRpcEpSet *pEpSet) { ...@@ -164,7 +164,7 @@ static void tscUpdateVgroupInfo(SSqlObj *pSql, SRpcEpSet *pEpSet) {
vgroupInfo.inUse = pEpSet->inUse; vgroupInfo.inUse = pEpSet->inUse;
vgroupInfo.numOfEps = pEpSet->numOfEps; vgroupInfo.numOfEps = pEpSet->numOfEps;
for (int32_t i = 0; i < vgroupInfo.numOfEps; i++) { for (int32_t i = 0; i < vgroupInfo.numOfEps; i++) {
strncpy(vgroupInfo.ep[i].fqdn, pEpSet->fqdn[i], TSDB_FQDN_LEN); tstrncpy(vgroupInfo.ep[i].fqdn, pEpSet->fqdn[i], TSDB_FQDN_LEN);
vgroupInfo.ep[i].port = pEpSet->port[i]; vgroupInfo.ep[i].port = pEpSet->port[i];
} }
...@@ -392,14 +392,17 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) { ...@@ -392,14 +392,17 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
// single table query error need to be handled here. // single table query error need to be handled here.
if ((cmd == TSDB_SQL_SELECT || cmd == TSDB_SQL_UPDATE_TAGS_VAL) && if ((cmd == TSDB_SQL_SELECT || cmd == TSDB_SQL_UPDATE_TAGS_VAL) &&
(((rpcMsg->code == TSDB_CODE_TDB_INVALID_TABLE_ID || // change the retry procedure (((rpcMsg->code == TSDB_CODE_TDB_INVALID_TABLE_ID ||
rpcMsg->code == TSDB_CODE_VND_INVALID_VGROUP_ID)) || rpcMsg->code == TSDB_CODE_VND_INVALID_VGROUP_ID)) ||
rpcMsg->code == TSDB_CODE_RPC_NETWORK_UNAVAIL || // change the retry procedure rpcMsg->code == TSDB_CODE_RPC_NETWORK_UNAVAIL ||
rpcMsg->code == TSDB_CODE_APP_NOT_READY)) { rpcMsg->code == TSDB_CODE_APP_NOT_READY)) {
if (TSDB_QUERY_HAS_TYPE(pQueryInfo->type, (TSDB_QUERY_TYPE_STABLE_SUBQUERY | TSDB_QUERY_TYPE_SUBQUERY | // 1. super table subquery
// 2. nest queries are all not updated the tablemeta and retry parse the sql after cleanup local tablemeta/vgroup id buffer
if ((TSDB_QUERY_HAS_TYPE(pQueryInfo->type, (TSDB_QUERY_TYPE_STABLE_SUBQUERY | TSDB_QUERY_TYPE_SUBQUERY |
TSDB_QUERY_TYPE_TAG_FILTER_QUERY)) && TSDB_QUERY_TYPE_TAG_FILTER_QUERY)) &&
!TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_PROJECTION_QUERY)) { !TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_PROJECTION_QUERY)) ||
(TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_NEST_SUBQUERY))) {
// do nothing in case of super table subquery // do nothing in case of super table subquery
} else { } else {
pSql->retry += 1; pSql->retry += 1;
...@@ -699,7 +702,9 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab ...@@ -699,7 +702,9 @@ static char *doSerializeTableInfo(SQueryTableMsg *pQueryMsg, SSqlObj *pSql, STab
tscDumpEpSetFromVgroupInfo(&pSql->epSet, &vgroupInfo); tscDumpEpSetFromVgroupInfo(&pSql->epSet, &vgroupInfo);
} }
pSql->epSet.inUse = rand()%pSql->epSet.numOfEps; if (pSql->epSet.numOfEps > 0){
pSql->epSet.inUse = rand()%pSql->epSet.numOfEps;
}
pQueryMsg->head.vgId = htonl(vgId); pQueryMsg->head.vgId = htonl(vgId);
STableIdInfo *pTableIdInfo = (STableIdInfo *)pMsg; STableIdInfo *pTableIdInfo = (STableIdInfo *)pMsg;
...@@ -976,7 +981,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -976,7 +981,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
} }
} }
if (query.numOfTags > 0) { if (query.numOfTags > 0 && query.tagColList != NULL) {
for (int32_t i = 0; i < query.numOfTags; ++i) { for (int32_t i = 0; i < query.numOfTags; ++i) {
SColumnInfo* pTag = &query.tagColList[i]; SColumnInfo* pTag = &query.tagColList[i];
...@@ -2025,8 +2030,12 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) { ...@@ -2025,8 +2030,12 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
assert(pTableMetaInfo->pTableMeta == NULL); assert(pTableMetaInfo->pTableMeta == NULL);
STableMeta* pTableMeta = tscCreateTableMetaFromMsg(pMetaMsg); STableMeta* pTableMeta = tscCreateTableMetaFromMsg(pMetaMsg);
if (pTableMeta == NULL){
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
if (!tIsValidSchema(pTableMeta->schema, pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.numOfTags)) { if (!tIsValidSchema(pTableMeta->schema, pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.numOfTags)) {
tscError("0x%"PRIx64" invalid table meta from mnode, name:%s", pSql->self, tNameGetTableName(&pTableMetaInfo->name)); tscError("0x%"PRIx64" invalid table meta from mnode, name:%s", pSql->self, tNameGetTableName(&pTableMetaInfo->name));
tfree(pTableMeta);
return TSDB_CODE_TSC_INVALID_VALUE; return TSDB_CODE_TSC_INVALID_VALUE;
} }
...@@ -2366,6 +2375,9 @@ int tscProcessSTableVgroupRsp(SSqlObj *pSql) { ...@@ -2366,6 +2375,9 @@ int tscProcessSTableVgroupRsp(SSqlObj *pSql) {
break; break;
} }
if (!pInfo){
continue;
}
int32_t size = 0; int32_t size = 0;
pInfo->vgroupList = createVgroupInfoFromMsg(pMsg, &size, pSql->self); pInfo->vgroupList = createVgroupInfoFromMsg(pMsg, &size, pSql->self);
pMsg += size; pMsg += size;
......
...@@ -963,8 +963,14 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { ...@@ -963,8 +963,14 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
strtolower(str, tableNameList); strtolower(str, tableNameList);
SArray* plist = taosArrayInit(4, POINTER_BYTES); SArray* plist = taosArrayInit(4, POINTER_BYTES);
if (plist == NULL) {
tfree(str);
return TSDB_CODE_TSC_OUT_OF_MEMORY;
}
SArray* vgroupList = taosArrayInit(4, POINTER_BYTES); SArray* vgroupList = taosArrayInit(4, POINTER_BYTES);
if (plist == NULL || vgroupList == NULL) { if (vgroupList == NULL) {
taosArrayDestroy(plist);
tfree(str); tfree(str);
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
...@@ -980,6 +986,8 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { ...@@ -980,6 +986,8 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
tscFreeSqlObj(pSql); tscFreeSqlObj(pSql);
taosArrayDestroyEx(plist, freeElem);
taosArrayDestroyEx(vgroupList, freeElem);
return code; return code;
} }
......
...@@ -271,7 +271,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf ...@@ -271,7 +271,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
if (pSql == NULL || numOfRows < 0) { if (pSql == NULL || numOfRows < 0) {
int64_t retryDelayTime = tscGetRetryDelayTime(pStream, pStream->interval.sliding, pStream->precision); int64_t retryDelayTime = tscGetRetryDelayTime(pStream, pStream->interval.sliding, pStream->precision);
tscError("0x%"PRIx64" stream:%p, retrieve data failed, code:0x%08x, retry in %" PRId64 " ms", pSql->self, pStream, numOfRows, retryDelayTime); tscError("stream:%p, retrieve data failed, code:0x%08x, retry in %" PRId64 " ms", pStream, numOfRows, retryDelayTime);
tscSetRetryTimer(pStream, pStream->pSql, retryDelayTime); tscSetRetryTimer(pStream, pStream->pSql, retryDelayTime);
return; return;
......
...@@ -2476,8 +2476,9 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) { ...@@ -2476,8 +2476,9 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
pState->states = calloc(pState->numOfSub, sizeof(*pState->states)); pState->states = calloc(pState->numOfSub, sizeof(*pState->states));
if (pState->states == NULL) { if (pState->states == NULL) {
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
tscDestroyGlobalMergerEnv(pMemoryBuf, pDesc,pState->numOfSub);
tscAsyncResultOnError(pSql); tscAsyncResultOnError(pSql);
tfree(pMemoryBuf);
return ret; return ret;
} }
...@@ -2705,7 +2706,6 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO ...@@ -2705,7 +2706,6 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
// release allocated resource // release allocated resource
tscDestroyGlobalMergerEnv(trsupport->pExtMemBuffer, trsupport->pOrderDescriptor, pState->numOfSub); tscDestroyGlobalMergerEnv(trsupport->pExtMemBuffer, trsupport->pOrderDescriptor, pState->numOfSub);
tscFreeRetrieveSup(pSql); tscFreeRetrieveSup(pSql);
// in case of second stage join subquery, invoke its callback function instead of regular QueueAsyncRes // in case of second stage join subquery, invoke its callback function instead of regular QueueAsyncRes
...@@ -2716,10 +2716,13 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO ...@@ -2716,10 +2716,13 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
int32_t code = pParentSql->res.code; int32_t code = pParentSql->res.code;
if ((code == TSDB_CODE_TDB_INVALID_TABLE_ID || code == TSDB_CODE_VND_INVALID_VGROUP_ID) && pParentSql->retry < pParentSql->maxRetry) { if ((code == TSDB_CODE_TDB_INVALID_TABLE_ID || code == TSDB_CODE_VND_INVALID_VGROUP_ID) && pParentSql->retry < pParentSql->maxRetry) {
// remove the cached tableMeta and vgroup id list, and then parse the sql again // remove the cached tableMeta and vgroup id list, and then parse the sql again
STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pParentSql->cmd, 0); SSqlCmd* pParentCmd = &pParentSql->cmd;
STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pParentCmd, 0);
tscRemoveTableMetaBuf(pTableMetaInfo, pParentSql->self); tscRemoveTableMetaBuf(pTableMetaInfo, pParentSql->self);
tscResetSqlCmd(&pParentSql->cmd, true); pParentCmd->pTableMetaMap = tscCleanupTableMetaMap(pParentCmd->pTableMetaMap);
pParentCmd->pTableMetaMap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
pParentSql->res.code = TSDB_CODE_SUCCESS; pParentSql->res.code = TSDB_CODE_SUCCESS;
pParentSql->retry++; pParentSql->retry++;
...@@ -2749,6 +2752,9 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO ...@@ -2749,6 +2752,9 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
} }
static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* pSql) { static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* pSql) {
if (trsupport->pExtMemBuffer == NULL){
return;
}
int32_t idx = trsupport->subqueryIndex; int32_t idx = trsupport->subqueryIndex;
SSqlObj * pParentSql = trsupport->pParentSql; SSqlObj * pParentSql = trsupport->pParentSql;
tOrderDescriptor *pDesc = trsupport->pOrderDescriptor; tOrderDescriptor *pDesc = trsupport->pOrderDescriptor;
......
...@@ -275,16 +275,6 @@ bool tscIsProjectionQuery(SQueryInfo* pQueryInfo) { ...@@ -275,16 +275,6 @@ bool tscIsProjectionQuery(SQueryInfo* pQueryInfo) {
f != TSDB_FUNC_DERIVATIVE) { f != TSDB_FUNC_DERIVATIVE) {
return false; return false;
} }
if (f < 0) {
SUdfInfo* pUdfInfo = taosArrayGet(pQueryInfo->pUdfInfo, -1 * f - 1);
if (pUdfInfo->funcType == TSDB_UDF_TYPE_AGGREGATE) {
return false;
}
continue;
}
} }
return true; return true;
...@@ -3190,8 +3180,10 @@ static void freeQueryInfoImpl(SQueryInfo* pQueryInfo) { ...@@ -3190,8 +3180,10 @@ static void freeQueryInfoImpl(SQueryInfo* pQueryInfo) {
} }
pQueryInfo->tsBuf = tsBufDestroy(pQueryInfo->tsBuf); pQueryInfo->tsBuf = tsBufDestroy(pQueryInfo->tsBuf);
pQueryInfo->fillType = 0;
tfree(pQueryInfo->fillVal); tfree(pQueryInfo->fillVal);
pQueryInfo->fillType = 0;
tfree(pQueryInfo->buf); tfree(pQueryInfo->buf);
taosArrayDestroy(pQueryInfo->pUpstream); taosArrayDestroy(pQueryInfo->pUpstream);
...@@ -3432,7 +3424,7 @@ STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, SName* name, STableM ...@@ -3432,7 +3424,7 @@ STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, SName* name, STableM
return NULL; return NULL;
} }
if (pTagCols != NULL) { if (pTagCols != NULL && pTableMetaInfo->pTableMeta != NULL) {
tscColumnListCopy(pTableMetaInfo->tagColList, pTagCols, pTableMetaInfo->pTableMeta->id.uid); tscColumnListCopy(pTableMetaInfo->tagColList, pTagCols, pTableMetaInfo->pTableMeta->id.uid);
} }
...@@ -3828,13 +3820,64 @@ static void tscSubqueryRetrieveCallback(void* param, TAOS_RES* tres, int code) { ...@@ -3828,13 +3820,64 @@ static void tscSubqueryRetrieveCallback(void* param, TAOS_RES* tres, int code) {
} }
} }
// todo handle the failure
static void tscSubqueryCompleteCallback(void* param, TAOS_RES* tres, int code) { static void tscSubqueryCompleteCallback(void* param, TAOS_RES* tres, int code) {
SSqlObj* pSql = tres;
SRetrieveSupport* ps = param;
if (pSql->res.code != TSDB_CODE_SUCCESS) {
SSqlObj* pParentSql = ps->pParentSql;
int32_t index = ps->subqueryIndex;
bool ret = subAndCheckDone(pSql, pParentSql, index);
tfree(ps);
pSql->param = NULL;
if (!ret) {
tscDebug("0x%"PRIx64" sub:0x%"PRIx64" orderOfSub:%d completed, not all subquery finished", pParentSql->self, pSql->self, index);
return;
}
// todo refactor
tscDebug("0x%"PRIx64" all subquery response received, retry", pParentSql->self);
SSqlCmd* pParentCmd = &pParentSql->cmd;
STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pParentCmd, 0);
tscRemoveTableMetaBuf(pTableMetaInfo, pParentSql->self);
pParentCmd->pTableMetaMap = tscCleanupTableMetaMap(pParentCmd->pTableMetaMap);
pParentCmd->pTableMetaMap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
pParentSql->res.code = TSDB_CODE_SUCCESS;
pParentSql->retry++;
tscDebug("0x%"PRIx64" retry parse sql and send query, prev error: %s, retry:%d", pParentSql->self,
tstrerror(code), pParentSql->retry);
code = tsParseSql(pParentSql, true);
if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) {
return;
}
if (code != TSDB_CODE_SUCCESS) {
pParentSql->res.code = code;
tscAsyncResultOnError(pParentSql);
return;
}
SQueryInfo *pQueryInfo = tscGetQueryInfo(pParentCmd);
executeQuery(pParentSql, pQueryInfo);
return;
}
taos_fetch_rows_a(tres, tscSubqueryRetrieveCallback, param); taos_fetch_rows_a(tres, tscSubqueryRetrieveCallback, param);
} }
// do execute the query according to the query execution plan // do execute the query according to the query execution plan
void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) { void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) {
int32_t code = TSDB_CODE_SUCCESS;
int32_t numOfInit = 0;
if (pSql->cmd.command == TSDB_SQL_RETRIEVE_EMPTY_RESULT) { if (pSql->cmd.command == TSDB_SQL_RETRIEVE_EMPTY_RESULT) {
(*pSql->fp)(pSql->param, pSql, 0); (*pSql->fp)(pSql->param, pSql, 0);
return; return;
...@@ -3849,7 +3892,12 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) { ...@@ -3849,7 +3892,12 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) {
pSql->pSubs = calloc(pSql->subState.numOfSub, POINTER_BYTES); pSql->pSubs = calloc(pSql->subState.numOfSub, POINTER_BYTES);
pSql->subState.states = calloc(pSql->subState.numOfSub, sizeof(int8_t)); pSql->subState.states = calloc(pSql->subState.numOfSub, sizeof(int8_t));
pthread_mutex_init(&pSql->subState.mutex, NULL); code = pthread_mutex_init(&pSql->subState.mutex, NULL);
if (pSql->pSubs == NULL || pSql->subState.states == NULL || code != TSDB_CODE_SUCCESS) {
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
goto _error;
}
for(int32_t i = 0; i < pSql->subState.numOfSub; ++i) { for(int32_t i = 0; i < pSql->subState.numOfSub; ++i) {
SQueryInfo* pSub = taosArrayGetP(pQueryInfo->pUpstream, i); SQueryInfo* pSub = taosArrayGetP(pQueryInfo->pUpstream, i);
...@@ -3857,45 +3905,71 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) { ...@@ -3857,45 +3905,71 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) {
pSql->cmd.active = pSub; pSql->cmd.active = pSub;
pSql->cmd.command = TSDB_SQL_SELECT; pSql->cmd.command = TSDB_SQL_SELECT;
// TODO handle memory failure
SSqlObj* pNew = (SSqlObj*)calloc(1, sizeof(SSqlObj)); SSqlObj* pNew = (SSqlObj*)calloc(1, sizeof(SSqlObj));
if (pNew == NULL) { if (pNew == NULL) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; code = TSDB_CODE_TSC_OUT_OF_MEMORY;
// return NULL; goto _error;
} }
pNew->pTscObj = pSql->pTscObj; pNew->pTscObj = pSql->pTscObj;
pNew->signature = pNew; pNew->signature = pNew;
pNew->sqlstr = strdup(pSql->sqlstr); // todo refactor pNew->sqlstr = strdup(pSql->sqlstr);
pNew->fp = tscSubqueryCompleteCallback; pNew->fp = tscSubqueryCompleteCallback;
pNew->maxRetry = pSql->maxRetry;
tsem_init(&pNew->rspSem, 0, 0); tsem_init(&pNew->rspSem, 0, 0);
SRetrieveSupport* ps = calloc(1, sizeof(SRetrieveSupport)); // todo use object id SRetrieveSupport* ps = calloc(1, sizeof(SRetrieveSupport)); // todo use object id
if (ps == NULL) {
tscFreeSqlObj(pNew);
goto _error;
}
ps->pParentSql = pSql; ps->pParentSql = pSql;
ps->subqueryIndex = i; ps->subqueryIndex = i;
pNew->param = ps; pNew->param = ps;
pSql->pSubs[i] = pNew; pSql->pSubs[i] = pNew;
registerSqlObj(pNew);
SSqlCmd* pCmd = &pNew->cmd; SSqlCmd* pCmd = &pNew->cmd;
pCmd->command = TSDB_SQL_SELECT; pCmd->command = TSDB_SQL_SELECT;
if (tscAddQueryInfo(pCmd) != TSDB_CODE_SUCCESS) { if ((code = tscAddQueryInfo(pCmd)) != TSDB_CODE_SUCCESS) {
goto _error;
} }
SQueryInfo* pNewQueryInfo = tscGetQueryInfo(pCmd); SQueryInfo* pNewQueryInfo = tscGetQueryInfo(pCmd);
tscQueryInfoCopy(pNewQueryInfo, pSub); tscQueryInfoCopy(pNewQueryInfo, pSub);
TSDB_QUERY_SET_TYPE(pNewQueryInfo->type, TSDB_QUERY_TYPE_NEST_SUBQUERY);
numOfInit++;
}
for(int32_t i = 0; i < pSql->subState.numOfSub; ++i) {
SSqlObj* psub = pSql->pSubs[i];
registerSqlObj(psub);
// create sub query to handle the sub query. // create sub query to handle the sub query.
executeQuery(pNew, pNewQueryInfo); SQueryInfo* pq = tscGetQueryInfo(&psub->cmd);
executeQuery(psub, pq);
} }
// merge sub query result and generate final results
return; return;
} }
pSql->cmd.active = pQueryInfo; pSql->cmd.active = pQueryInfo;
doExecuteQuery(pSql, pQueryInfo); doExecuteQuery(pSql, pQueryInfo);
return;
_error:
for(int32_t i = 0; i < numOfInit; ++i) {
SSqlObj* p = pSql->pSubs[i];
tscFreeSqlObj(p);
}
pSql->res.code = code;
pSql->subState.numOfSub = 0; // not initialized sub query object will not be freed
tfree(pSql->subState.states);
tfree(pSql->pSubs);
tscAsyncResultOnError(pSql);
} }
int16_t tscGetJoinTagColIdByUid(STagCond* pTagCond, uint64_t uid) { int16_t tscGetJoinTagColIdByUid(STagCond* pTagCond, uint64_t uid) {
...@@ -4349,7 +4423,7 @@ uint32_t tscGetTableMetaSize(STableMeta* pTableMeta) { ...@@ -4349,7 +4423,7 @@ uint32_t tscGetTableMetaSize(STableMeta* pTableMeta) {
assert(pTableMeta != NULL); assert(pTableMeta != NULL);
int32_t totalCols = 0; int32_t totalCols = 0;
if (pTableMeta->tableInfo.numOfColumns >= 0 && pTableMeta->tableInfo.numOfTags >= 0) { if (pTableMeta->tableInfo.numOfColumns >= 0) {
totalCols = pTableMeta->tableInfo.numOfColumns + pTableMeta->tableInfo.numOfTags; totalCols = pTableMeta->tableInfo.numOfColumns + pTableMeta->tableInfo.numOfTags;
} }
...@@ -4382,7 +4456,7 @@ int32_t tscCreateTableMetaFromSTableMeta(STableMeta* pChild, const char* name, v ...@@ -4382,7 +4456,7 @@ int32_t tscCreateTableMetaFromSTableMeta(STableMeta* pChild, const char* name, v
pChild->sversion = p->sversion; pChild->sversion = p->sversion;
pChild->tversion = p->tversion; pChild->tversion = p->tversion;
memcpy(&pChild->tableInfo, &p->tableInfo, sizeof(STableInfo)); memcpy(&pChild->tableInfo, &p->tableInfo, sizeof(STableComInfo));
int32_t total = pChild->tableInfo.numOfColumns + pChild->tableInfo.numOfTags; int32_t total = pChild->tableInfo.numOfColumns + pChild->tableInfo.numOfTags;
memcpy(pChild->schema, p->schema, sizeof(SSchema) *total); memcpy(pChild->schema, p->schema, sizeof(SSchema) *total);
...@@ -4749,7 +4823,7 @@ static int32_t doAddTableName(char* nextStr, char** str, SArray* pNameArray, SSq ...@@ -4749,7 +4823,7 @@ static int32_t doAddTableName(char* nextStr, char** str, SArray* pNameArray, SSq
int32_t len = 0; int32_t len = 0;
if (nextStr == NULL) { if (nextStr == NULL) {
strncpy(tablename, *str, TSDB_TABLE_FNAME_LEN); tstrncpy(tablename, *str, TSDB_TABLE_FNAME_LEN);
len = (int32_t) strlen(tablename); len = (int32_t) strlen(tablename);
} else { } else {
len = (int32_t)(nextStr - (*str)); len = (int32_t)(nextStr - (*str));
......
...@@ -38,7 +38,7 @@ uint16_t tsDnodeDnodePort = 6035; // udp/tcp ...@@ -38,7 +38,7 @@ uint16_t tsDnodeDnodePort = 6035; // udp/tcp
uint16_t tsSyncPort = 6040; uint16_t tsSyncPort = 6040;
uint16_t tsArbitratorPort = 6042; uint16_t tsArbitratorPort = 6042;
int32_t tsStatusInterval = 1; // second int32_t tsStatusInterval = 1; // second
int32_t tsNumOfMnodes = 3; int32_t tsNumOfMnodes = 1;
int8_t tsEnableVnodeBak = 1; int8_t tsEnableVnodeBak = 1;
int8_t tsEnableTelemetryReporting = 1; int8_t tsEnableTelemetryReporting = 1;
int8_t tsArbOnline = 0; int8_t tsArbOnline = 0;
......
...@@ -319,7 +319,7 @@ int32_t tNameGetDbName(const SName* name, char* dst) { ...@@ -319,7 +319,7 @@ int32_t tNameGetDbName(const SName* name, char* dst) {
int32_t tNameGetFullDbName(const SName* name, char* dst) { int32_t tNameGetFullDbName(const SName* name, char* dst) {
assert(name != NULL && dst != NULL); assert(name != NULL && dst != NULL);
snprintf(dst, TSDB_ACCT_ID_LEN + TS_PATH_DELIMITER_LEN + TSDB_DB_NAME_LEN, snprintf(dst, TSDB_ACCT_ID_LEN + TS_PATH_DELIMITER_LEN + TSDB_DB_NAME_LEN, // there is a over write risk
"%s.%s", name->acctId, name->dbname); "%s.%s", name->acctId, name->dbname);
return 0; return 0;
} }
......
...@@ -163,5 +163,8 @@ namespace TDengineDriver ...@@ -163,5 +163,8 @@ namespace TDengineDriver
[DllImport("taos", EntryPoint = "taos_close", CallingConvention = CallingConvention.Cdecl)] [DllImport("taos", EntryPoint = "taos_close", CallingConvention = CallingConvention.Cdecl)]
static extern public int Close(IntPtr taos); static extern public int Close(IntPtr taos);
//get precisionin parameter restultset
[DllImport("taos", EntryPoint = "taos_result_precision", CallingConvention = CallingConvention.Cdecl)]
static extern public int ResultPrecision(IntPtr taos);
} }
} }
...@@ -7,11 +7,11 @@ import platform ...@@ -7,11 +7,11 @@ import platform
def _convert_millisecond_to_datetime(milli): def _convert_millisecond_to_datetime(milli):
return datetime.datetime.fromtimestamp(milli / 1000.0) return datetime.datetime.fromtimestamp(0) + datetime.timedelta(seconds=milli/1000.0)
def _convert_microsecond_to_datetime(micro): def _convert_microsecond_to_datetime(micro):
return datetime.datetime.fromtimestamp(micro / 1000000.0) return datetime.datetime.fromtimestamp(0) + datetime.timedelta(seconds=micro / 1000000.0)
def _convert_nanosecond_to_datetime(nanosec): def _convert_nanosecond_to_datetime(nanosec):
......
...@@ -110,19 +110,18 @@ typedef struct TAOS_MULTI_BIND { ...@@ -110,19 +110,18 @@ typedef struct TAOS_MULTI_BIND {
int num; int num;
} TAOS_MULTI_BIND; } TAOS_MULTI_BIND;
DLL_EXPORT TAOS_STMT *taos_stmt_init(TAOS *taos); DLL_EXPORT TAOS_STMT *taos_stmt_init(TAOS *taos);
DLL_EXPORT int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length); DLL_EXPORT int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length);
DLL_EXPORT int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags); DLL_EXPORT int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags);
DLL_EXPORT int taos_stmt_set_tbname(TAOS_STMT* stmt, const char* name); DLL_EXPORT int taos_stmt_set_tbname(TAOS_STMT* stmt, const char* name);
DLL_EXPORT int taos_stmt_set_sub_tbname(TAOS_STMT* stmt, const char* name); DLL_EXPORT int taos_stmt_set_sub_tbname(TAOS_STMT* stmt, const char* name);
DLL_EXPORT int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert); DLL_EXPORT int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert);
DLL_EXPORT int taos_stmt_num_params(TAOS_STMT *stmt, int *nums); DLL_EXPORT int taos_stmt_num_params(TAOS_STMT *stmt, int *nums);
int taos_stmt_get_param(TAOS_STMT *stmt, int idx, int *type, int *bytes); DLL_EXPORT int taos_stmt_get_param(TAOS_STMT *stmt, int idx, int *type, int *bytes);
DLL_EXPORT int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind); DLL_EXPORT int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind);
int taos_stmt_bind_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind); DLL_EXPORT int taos_stmt_bind_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind);
int taos_stmt_bind_single_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int colIdx); DLL_EXPORT int taos_stmt_bind_single_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int colIdx);
DLL_EXPORT int taos_stmt_add_batch(TAOS_STMT *stmt); DLL_EXPORT int taos_stmt_add_batch(TAOS_STMT *stmt);
DLL_EXPORT int taos_stmt_execute(TAOS_STMT *stmt); DLL_EXPORT int taos_stmt_execute(TAOS_STMT *stmt);
DLL_EXPORT TAOS_RES * taos_stmt_use_result(TAOS_STMT *stmt); DLL_EXPORT TAOS_RES * taos_stmt_use_result(TAOS_STMT *stmt);
...@@ -141,7 +140,6 @@ DLL_EXPORT int taos_select_db(TAOS *taos, const char *db); ...@@ -141,7 +140,6 @@ DLL_EXPORT int taos_select_db(TAOS *taos, const char *db);
DLL_EXPORT int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields); DLL_EXPORT int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields);
DLL_EXPORT void taos_stop_query(TAOS_RES *res); DLL_EXPORT void taos_stop_query(TAOS_RES *res);
DLL_EXPORT bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col); DLL_EXPORT bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col);
DLL_EXPORT int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows); DLL_EXPORT int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows);
DLL_EXPORT int taos_validate_sql(TAOS *taos, const char *sql); DLL_EXPORT int taos_validate_sql(TAOS *taos, const char *sql);
......
...@@ -365,6 +365,7 @@ do { \ ...@@ -365,6 +365,7 @@ do { \
#define TSDB_QUERY_TYPE_MULTITABLE_QUERY 0x200u #define TSDB_QUERY_TYPE_MULTITABLE_QUERY 0x200u
#define TSDB_QUERY_TYPE_FILE_INSERT 0x400u // insert data from file #define TSDB_QUERY_TYPE_FILE_INSERT 0x400u // insert data from file
#define TSDB_QUERY_TYPE_STMT_INSERT 0x800u // stmt insert type #define TSDB_QUERY_TYPE_STMT_INSERT 0x800u // stmt insert type
#define TSDB_QUERY_TYPE_NEST_SUBQUERY 0x1000u // nested sub query
#define TSDB_QUERY_HAS_TYPE(x, _type) (((x) & (_type)) != 0) #define TSDB_QUERY_HAS_TYPE(x, _type) (((x) & (_type)) != 0)
#define TSDB_QUERY_SET_TYPE(x, _type) ((x) |= (_type)) #define TSDB_QUERY_SET_TYPE(x, _type) ((x) |= (_type))
......
...@@ -27,7 +27,7 @@ typedef struct { ...@@ -27,7 +27,7 @@ typedef struct {
int32_t vgId; int32_t vgId;
char user[TSDB_USER_LEN]; char user[TSDB_USER_LEN];
char pass[TSDB_KEY_LEN]; char pass[TSDB_KEY_LEN];
char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN]; char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN]; // size must same with SVnodeObj.db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN]
FCqWrite cqWrite; FCqWrite cqWrite;
} SCqCfg; } SCqCfg;
......
此差异已折叠。
...@@ -1264,7 +1264,7 @@ static int taosGetTableDes( ...@@ -1264,7 +1264,7 @@ static int taosGetTableDes(
fields[TSDB_DESCRIBE_METRIC_FIELD_INDEX].bytes + 1)); fields[TSDB_DESCRIBE_METRIC_FIELD_INDEX].bytes + 1));
tstrncpy(tableDes->cols[count].type, tstrncpy(tableDes->cols[count].type,
(char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], (char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
min(16, fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes) + 1); min(16, fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes + 1));
tableDes->cols[count].length = tableDes->cols[count].length =
*((int *)row[TSDB_DESCRIBE_METRIC_LENGTH_INDEX]); *((int *)row[TSDB_DESCRIBE_METRIC_LENGTH_INDEX]);
tstrncpy(tableDes->cols[count].note, tstrncpy(tableDes->cols[count].note,
......
...@@ -38,7 +38,7 @@ static void *taosProcessAlarmSignal(void *tharg) { ...@@ -38,7 +38,7 @@ static void *taosProcessAlarmSignal(void *tharg) {
struct sigevent sevent = {{0}}; struct sigevent sevent = {{0}};
setThreadName("alarmSignal"); setThreadName("tmr");
#ifdef _ALPINE #ifdef _ALPINE
sevent.sigev_notify = SIGEV_THREAD; sevent.sigev_notify = SIGEV_THREAD;
......
...@@ -268,7 +268,7 @@ void httpJsonTimestamp(JsonBuf* buf, int64_t t, int32_t timePrecision) { ...@@ -268,7 +268,7 @@ void httpJsonTimestamp(JsonBuf* buf, int64_t t, int32_t timePrecision) {
int32_t fractionLen; int32_t fractionLen;
char* format = NULL; char* format = NULL;
time_t quot = 0; time_t quot = 0;
long mod = 0; int64_t mod = 0;
switch (timePrecision) { switch (timePrecision) {
case TSDB_TIME_PRECISION_MILLI: { case TSDB_TIME_PRECISION_MILLI: {
......
...@@ -60,7 +60,7 @@ typedef struct STableComInfo { ...@@ -60,7 +60,7 @@ typedef struct STableComInfo {
typedef struct STableMeta { typedef struct STableMeta {
int32_t vgId; int32_t vgId;
STableId id; STableId id;
uint8_t tableType; int8_t tableType;
char sTableName[TSDB_TABLE_FNAME_LEN]; // super table name char sTableName[TSDB_TABLE_FNAME_LEN]; // super table name
uint64_t suid; // super table id uint64_t suid; // super table id
int16_t sversion; int16_t sversion;
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "tcompare.h" #include "tcompare.h"
#include "tscompression.h" #include "tscompression.h"
#include "qScript.h" #include "qScript.h"
#include "tscLog.h"
#define IS_MASTER_SCAN(runtime) ((runtime)->scanFlag == MASTER_SCAN) #define IS_MASTER_SCAN(runtime) ((runtime)->scanFlag == MASTER_SCAN)
#define IS_REVERSE_SCAN(runtime) ((runtime)->scanFlag == REVERSE_SCAN) #define IS_REVERSE_SCAN(runtime) ((runtime)->scanFlag == REVERSE_SCAN)
...@@ -787,7 +788,7 @@ static int32_t getNumOfRowsInTimeWindow(SQueryRuntimeEnv* pRuntimeEnv, SDataBloc ...@@ -787,7 +788,7 @@ static int32_t getNumOfRowsInTimeWindow(SQueryRuntimeEnv* pRuntimeEnv, SDataBloc
int32_t step = GET_FORWARD_DIRECTION_FACTOR(order); int32_t step = GET_FORWARD_DIRECTION_FACTOR(order);
if (QUERY_IS_ASC_QUERY(pQueryAttr)) { if (QUERY_IS_ASC_QUERY(pQueryAttr)) {
if (ekey < pDataBlockInfo->window.ekey) { if (ekey < pDataBlockInfo->window.ekey && pPrimaryColumn) {
num = getForwardStepsInBlock(pDataBlockInfo->rows, searchFn, ekey, startPos, order, pPrimaryColumn); num = getForwardStepsInBlock(pDataBlockInfo->rows, searchFn, ekey, startPos, order, pPrimaryColumn);
if (updateLastKey) { // update the last key if (updateLastKey) { // update the last key
item->lastKey = pPrimaryColumn[startPos + (num - 1)] + step; item->lastKey = pPrimaryColumn[startPos + (num - 1)] + step;
...@@ -799,7 +800,7 @@ static int32_t getNumOfRowsInTimeWindow(SQueryRuntimeEnv* pRuntimeEnv, SDataBloc ...@@ -799,7 +800,7 @@ static int32_t getNumOfRowsInTimeWindow(SQueryRuntimeEnv* pRuntimeEnv, SDataBloc
} }
} }
} else { // desc } else { // desc
if (ekey > pDataBlockInfo->window.skey) { if (ekey > pDataBlockInfo->window.skey && pPrimaryColumn) {
num = getForwardStepsInBlock(pDataBlockInfo->rows, searchFn, ekey, startPos, order, pPrimaryColumn); num = getForwardStepsInBlock(pDataBlockInfo->rows, searchFn, ekey, startPos, order, pPrimaryColumn);
if (updateLastKey) { // update the last key if (updateLastKey) { // update the last key
item->lastKey = pPrimaryColumn[startPos - (num - 1)] + step; item->lastKey = pPrimaryColumn[startPos - (num - 1)] + step;
...@@ -1336,6 +1337,10 @@ static void doWindowBorderInterpolation(SOperatorInfo* pOperatorInfo, SSDataBloc ...@@ -1336,6 +1337,10 @@ static void doWindowBorderInterpolation(SOperatorInfo* pOperatorInfo, SSDataBloc
assert(pBlock != NULL); assert(pBlock != NULL);
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQueryAttr->order.order); int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQueryAttr->order.order);
if (pBlock->pDataBlock == NULL){
tscError("pBlock->pDataBlock == NULL");
return;
}
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, 0); SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, 0);
TSKEY *tsCols = (TSKEY *)(pColInfo->pData); TSKEY *tsCols = (TSKEY *)(pColInfo->pData);
...@@ -3600,6 +3605,7 @@ STableQueryInfo* createTmpTableQueryInfo(STimeWindow win) { ...@@ -3600,6 +3605,7 @@ STableQueryInfo* createTmpTableQueryInfo(STimeWindow win) {
int32_t initialSize = 16; int32_t initialSize = 16;
int32_t code = initResultRowInfo(&pTableQueryInfo->resInfo, initialSize, TSDB_DATA_TYPE_INT); int32_t code = initResultRowInfo(&pTableQueryInfo->resInfo, initialSize, TSDB_DATA_TYPE_INT);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
tfree(pTableQueryInfo);
return NULL; return NULL;
} }
...@@ -5555,6 +5561,8 @@ static SSDataBlock* doIntervalAgg(void* param, bool* newgroup) { ...@@ -5555,6 +5561,8 @@ static SSDataBlock* doIntervalAgg(void* param, bool* newgroup) {
break; break;
} }
setTagValue(pOperator, pRuntimeEnv->current->pTable, pIntervalInfo->pCtx, pOperator->numOfOutput);
// the pDataBlock are always the same one, no need to call this again // the pDataBlock are always the same one, no need to call this again
setInputDataBlock(pOperator, pIntervalInfo->pCtx, pBlock, pQueryAttr->order.order); setInputDataBlock(pOperator, pIntervalInfo->pCtx, pBlock, pQueryAttr->order.order);
hashIntervalAgg(pOperator, &pIntervalInfo->resultRowInfo, pBlock, 0); hashIntervalAgg(pOperator, &pIntervalInfo->resultRowInfo, pBlock, 0);
...@@ -7302,9 +7310,7 @@ void destroyUdfInfo(SUdfInfo* pUdfInfo) { ...@@ -7302,9 +7310,7 @@ void destroyUdfInfo(SUdfInfo* pUdfInfo) {
tfree(pUdfInfo); tfree(pUdfInfo);
} }
static char* getUdfFuncName(char* name, int type) { static char* getUdfFuncName(char* funcname, char* name, int type) {
char* funcname = calloc(1, TSDB_FUNCTIONS_NAME_MAX_LENGTH + 10);
switch (type) { switch (type) {
case TSDB_UDF_FUNC_NORMAL: case TSDB_UDF_FUNC_NORMAL:
strcpy(funcname, name); strcpy(funcname, name);
...@@ -7375,19 +7381,20 @@ int32_t initUdfInfo(SUdfInfo* pUdfInfo) { ...@@ -7375,19 +7381,20 @@ int32_t initUdfInfo(SUdfInfo* pUdfInfo) {
return TSDB_CODE_QRY_SYS_ERROR; return TSDB_CODE_QRY_SYS_ERROR;
} }
pUdfInfo->funcs[TSDB_UDF_FUNC_NORMAL] = taosLoadSym(pUdfInfo->handle, getUdfFuncName(pUdfInfo->name, TSDB_UDF_FUNC_NORMAL)); char funcname[TSDB_FUNCTIONS_NAME_MAX_LENGTH + 10] = {0};
pUdfInfo->funcs[TSDB_UDF_FUNC_NORMAL] = taosLoadSym(pUdfInfo->handle, getUdfFuncName(funcname, pUdfInfo->name, TSDB_UDF_FUNC_NORMAL));
if (NULL == pUdfInfo->funcs[TSDB_UDF_FUNC_NORMAL]) { if (NULL == pUdfInfo->funcs[TSDB_UDF_FUNC_NORMAL]) {
return TSDB_CODE_QRY_SYS_ERROR; return TSDB_CODE_QRY_SYS_ERROR;
} }
pUdfInfo->funcs[TSDB_UDF_FUNC_INIT] = taosLoadSym(pUdfInfo->handle, getUdfFuncName(pUdfInfo->name, TSDB_UDF_FUNC_INIT)); pUdfInfo->funcs[TSDB_UDF_FUNC_INIT] = taosLoadSym(pUdfInfo->handle, getUdfFuncName(funcname, pUdfInfo->name, TSDB_UDF_FUNC_INIT));
if (pUdfInfo->funcType == TSDB_UDF_TYPE_AGGREGATE) { if (pUdfInfo->funcType == TSDB_UDF_TYPE_AGGREGATE) {
pUdfInfo->funcs[TSDB_UDF_FUNC_FINALIZE] = taosLoadSym(pUdfInfo->handle, getUdfFuncName(pUdfInfo->name, TSDB_UDF_FUNC_FINALIZE)); pUdfInfo->funcs[TSDB_UDF_FUNC_FINALIZE] = taosLoadSym(pUdfInfo->handle, getUdfFuncName(funcname, pUdfInfo->name, TSDB_UDF_FUNC_FINALIZE));
pUdfInfo->funcs[TSDB_UDF_FUNC_MERGE] = taosLoadSym(pUdfInfo->handle, getUdfFuncName(pUdfInfo->name, TSDB_UDF_FUNC_MERGE)); pUdfInfo->funcs[TSDB_UDF_FUNC_MERGE] = taosLoadSym(pUdfInfo->handle, getUdfFuncName(funcname, pUdfInfo->name, TSDB_UDF_FUNC_MERGE));
} }
pUdfInfo->funcs[TSDB_UDF_FUNC_DESTROY] = taosLoadSym(pUdfInfo->handle, getUdfFuncName(pUdfInfo->name, TSDB_UDF_FUNC_DESTROY)); pUdfInfo->funcs[TSDB_UDF_FUNC_DESTROY] = taosLoadSym(pUdfInfo->handle, getUdfFuncName(funcname, pUdfInfo->name, TSDB_UDF_FUNC_DESTROY));
if (pUdfInfo->funcs[TSDB_UDF_FUNC_INIT]) { if (pUdfInfo->funcs[TSDB_UDF_FUNC_INIT]) {
return (*(udfInitFunc)pUdfInfo->funcs[TSDB_UDF_FUNC_INIT])(&pUdfInfo->init); return (*(udfInitFunc)pUdfInfo->funcs[TSDB_UDF_FUNC_INIT])(&pUdfInfo->init);
...@@ -7459,10 +7466,12 @@ int32_t createQueryFunc(SQueriedTableInfo* pTableInfo, int32_t numOfOutput, SExp ...@@ -7459,10 +7466,12 @@ int32_t createQueryFunc(SQueriedTableInfo* pTableInfo, int32_t numOfOutput, SExp
int32_t j = getColumnIndexInSource(pTableInfo, &pExprs[i].base, pTagCols); int32_t j = getColumnIndexInSource(pTableInfo, &pExprs[i].base, pTagCols);
if (TSDB_COL_IS_TAG(pExprs[i].base.colInfo.flag)) { if (TSDB_COL_IS_TAG(pExprs[i].base.colInfo.flag)) {
if (j < TSDB_TBNAME_COLUMN_INDEX || j >= pTableInfo->numOfTags) { if (j < TSDB_TBNAME_COLUMN_INDEX || j >= pTableInfo->numOfTags) {
tfree(pExprs);
return TSDB_CODE_QRY_INVALID_MSG; return TSDB_CODE_QRY_INVALID_MSG;
} }
} else { } else {
if (j < PRIMARYKEY_TIMESTAMP_COL_INDEX || j >= pTableInfo->numOfCols) { if (j < PRIMARYKEY_TIMESTAMP_COL_INDEX || j >= pTableInfo->numOfCols) {
tfree(pExprs);
return TSDB_CODE_QRY_INVALID_MSG; return TSDB_CODE_QRY_INVALID_MSG;
} }
} }
...@@ -7482,6 +7491,7 @@ int32_t createQueryFunc(SQueriedTableInfo* pTableInfo, int32_t numOfOutput, SExp ...@@ -7482,6 +7491,7 @@ int32_t createQueryFunc(SQueriedTableInfo* pTableInfo, int32_t numOfOutput, SExp
int32_t ret = cloneExprFilterInfo(&pExprs[i].base.flist.filterInfo, pExprMsg[i]->flist.filterInfo, int32_t ret = cloneExprFilterInfo(&pExprs[i].base.flist.filterInfo, pExprMsg[i]->flist.filterInfo,
pExprMsg[i]->flist.numOfFilters); pExprMsg[i]->flist.numOfFilters);
if (ret) { if (ret) {
tfree(pExprs);
return ret; return ret;
} }
} }
...@@ -7600,7 +7610,7 @@ SGroupbyExpr *createGroupbyExprFromMsg(SQueryTableMsg *pQueryMsg, SColIndex *pCo ...@@ -7600,7 +7610,7 @@ SGroupbyExpr *createGroupbyExprFromMsg(SQueryTableMsg *pQueryMsg, SColIndex *pCo
int32_t doCreateFilterInfo(SColumnInfo* pCols, int32_t numOfCols, int32_t numOfFilterCols, SSingleColumnFilterInfo** pFilterInfo, uint64_t qId) { int32_t doCreateFilterInfo(SColumnInfo* pCols, int32_t numOfCols, int32_t numOfFilterCols, SSingleColumnFilterInfo** pFilterInfo, uint64_t qId) {
*pFilterInfo = calloc(1, sizeof(SSingleColumnFilterInfo) * numOfFilterCols); *pFilterInfo = calloc(1, sizeof(SSingleColumnFilterInfo) * numOfFilterCols);
if (pFilterInfo == NULL) { if (*pFilterInfo == NULL) {
return TSDB_CODE_QRY_OUT_OF_MEMORY; return TSDB_CODE_QRY_OUT_OF_MEMORY;
} }
......
...@@ -391,11 +391,18 @@ int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t ...@@ -391,11 +391,18 @@ int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t
}; };
case TSDB_DATA_TYPE_NCHAR: { // todo handle the var string compare case TSDB_DATA_TYPE_NCHAR: { // todo handle the var string compare
int32_t ret = tasoUcs4Compare(f1, f2, bytes); int32_t len1 = varDataLen(f1);
if (ret == 0) { int32_t len2 = varDataLen(f2);
return 0;
if (len1 != len2) {
return len1 > len2 ? 1 : -1;
} else {
int32_t ret = tasoUcs4Compare(varDataVal(f1), varDataVal(f2), len1);
if (ret == 0) {
return 0;
}
return (ret < 0) ? -1 : 1;
} }
return (ret < 0) ? -1 : 1;
}; };
case TSDB_DATA_TYPE_UTINYINT: DEFAULT_COMP(GET_UINT8_VAL(f1), GET_UINT8_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_USMALLINT: DEFAULT_COMP(GET_UINT16_VAL(f1), GET_UINT16_VAL(f2));
......
...@@ -40,7 +40,7 @@ static SQueryNode* createQueryNode(int32_t type, const char* name, SQueryNode** ...@@ -40,7 +40,7 @@ static SQueryNode* createQueryNode(int32_t type, const char* name, SQueryNode**
pNode->info.type = type; pNode->info.type = type;
pNode->info.name = strdup(name); pNode->info.name = strdup(name);
if (pTableInfo->id.uid != 0) { // it is a true table if (pTableInfo->id.uid != 0 && pTableInfo->tableName) { // it is a true table
pNode->tableInfo.id = pTableInfo->id; pNode->tableInfo.id = pTableInfo->id;
pNode->tableInfo.tableName = strdup(pTableInfo->tableName); pNode->tableInfo.tableName = strdup(pTableInfo->tableName);
} }
...@@ -222,6 +222,7 @@ SArray* createQueryPlanImpl(SQueryInfo* pQueryInfo) { ...@@ -222,6 +222,7 @@ SArray* createQueryPlanImpl(SQueryInfo* pQueryInfo) {
if (pQueryInfo->numOfTables > 1) { // it is a join query if (pQueryInfo->numOfTables > 1) { // it is a join query
// 1. separate the select clause according to table // 1. separate the select clause according to table
taosArrayDestroy(upstream);
upstream = taosArrayInit(5, POINTER_BYTES); upstream = taosArrayInit(5, POINTER_BYTES);
for(int32_t i = 0; i < pQueryInfo->numOfTables; ++i) { for(int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
...@@ -231,6 +232,7 @@ SArray* createQueryPlanImpl(SQueryInfo* pQueryInfo) { ...@@ -231,6 +232,7 @@ SArray* createQueryPlanImpl(SQueryInfo* pQueryInfo) {
SArray* exprList = taosArrayInit(4, POINTER_BYTES); SArray* exprList = taosArrayInit(4, POINTER_BYTES);
if (tscExprCopy(exprList, pQueryInfo->exprList, uid, true) != 0) { if (tscExprCopy(exprList, pQueryInfo->exprList, uid, true) != 0) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
tscExprDestroy(exprList);
exit(-1); exit(-1);
} }
...@@ -245,6 +247,8 @@ SArray* createQueryPlanImpl(SQueryInfo* pQueryInfo) { ...@@ -245,6 +247,8 @@ SArray* createQueryPlanImpl(SQueryInfo* pQueryInfo) {
// 4. add the projection query node // 4. add the projection query node
SQueryNode* pNode = doAddTableColumnNode(pQueryInfo, pTableMetaInfo, &info, exprList, tableColumnList); SQueryNode* pNode = doAddTableColumnNode(pQueryInfo, pTableMetaInfo, &info, exprList, tableColumnList);
tscColumnListDestroy(tableColumnList);
tscExprDestroy(exprList);
taosArrayPush(upstream, &pNode); taosArrayPush(upstream, &pNode);
} }
......
...@@ -78,8 +78,9 @@ static char* doDecompressData(void* data, int32_t srcSize, int32_t *dst, SDiskba ...@@ -78,8 +78,9 @@ static char* doDecompressData(void* data, int32_t srcSize, int32_t *dst, SDiskba
} }
*dst = tsDecompressString(data, srcSize, 1, pResultBuf->assistBuf, pResultBuf->pageSize, ONE_STAGE_COMP, NULL, 0); *dst = tsDecompressString(data, srcSize, 1, pResultBuf->assistBuf, pResultBuf->pageSize, ONE_STAGE_COMP, NULL, 0);
if (*dst > 0) {
memcpy(data, pResultBuf->assistBuf, *dst); memcpy(data, pResultBuf->assistBuf, *dst);
}
return data; return data;
} }
......
...@@ -378,9 +378,11 @@ ScriptEnv* getScriptEnvFromPool() { ...@@ -378,9 +378,11 @@ ScriptEnv* getScriptEnvFromPool() {
return NULL; return NULL;
} }
SListNode *pNode = tdListPopHead(pool->scriptEnvs); SListNode *pNode = tdListPopHead(pool->scriptEnvs);
tdListNodeGetData(pool->scriptEnvs, pNode, (void *)(&pEnv)); if (pNode){
listNodeFree(pNode); tdListNodeGetData(pool->scriptEnvs, pNode, (void *)(&pEnv));
listNodeFree(pNode);
}
pool->cSize--; pool->cSize--;
pthread_mutex_unlock(&pool->mutex); pthread_mutex_unlock(&pool->mutex);
return pEnv; return pEnv;
......
...@@ -142,14 +142,17 @@ tSqlExpr *tSqlExprCreateIdValue(SStrToken *pToken, int32_t optrType) { ...@@ -142,14 +142,17 @@ tSqlExpr *tSqlExprCreateIdValue(SStrToken *pToken, int32_t optrType) {
} }
if (optrType == TK_NULL) { if (optrType == TK_NULL) {
pToken->type = TSDB_DATA_TYPE_NULL; if (pToken){
tVariantCreate(&pSqlExpr->value, pToken); pToken->type = TSDB_DATA_TYPE_NULL;
tVariantCreate(&pSqlExpr->value, pToken);
}
pSqlExpr->tokenId = optrType; pSqlExpr->tokenId = optrType;
pSqlExpr->type = SQL_NODE_VALUE; pSqlExpr->type = SQL_NODE_VALUE;
} else if (optrType == TK_INTEGER || optrType == TK_STRING || optrType == TK_FLOAT || optrType == TK_BOOL) { } else if (optrType == TK_INTEGER || optrType == TK_STRING || optrType == TK_FLOAT || optrType == TK_BOOL) {
toTSDBType(pToken->type); if (pToken) {
toTSDBType(pToken->type);
tVariantCreate(&pSqlExpr->value, pToken); tVariantCreate(&pSqlExpr->value, pToken);
}
pSqlExpr->tokenId = optrType; pSqlExpr->tokenId = optrType;
pSqlExpr->type = SQL_NODE_VALUE; pSqlExpr->type = SQL_NODE_VALUE;
} else if (optrType == TK_NOW) { } else if (optrType == TK_NOW) {
...@@ -162,9 +165,11 @@ tSqlExpr *tSqlExprCreateIdValue(SStrToken *pToken, int32_t optrType) { ...@@ -162,9 +165,11 @@ tSqlExpr *tSqlExprCreateIdValue(SStrToken *pToken, int32_t optrType) {
} else if (optrType == TK_VARIABLE) { } else if (optrType == TK_VARIABLE) {
// use nanosecond by default // use nanosecond by default
// TODO set value after getting database precision // TODO set value after getting database precision
int32_t ret = parseAbsoluteDuration(pToken->z, pToken->n, &pSqlExpr->value.i64, TSDB_TIME_PRECISION_NANO); if (pToken) {
if (ret != TSDB_CODE_SUCCESS) { int32_t ret = parseAbsoluteDuration(pToken->z, pToken->n, &pSqlExpr->value.i64, TSDB_TIME_PRECISION_NANO);
terrno = TSDB_CODE_TSC_SQL_SYNTAX_ERROR; if (ret != TSDB_CODE_SUCCESS) {
terrno = TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
}
} }
pSqlExpr->flags |= 1 << EXPR_FLAG_NS_TIMESTAMP; pSqlExpr->flags |= 1 << EXPR_FLAG_NS_TIMESTAMP;
...@@ -340,8 +345,9 @@ static FORCE_INLINE int32_t tStrTokenCompare(SStrToken* left, SStrToken* right) ...@@ -340,8 +345,9 @@ static FORCE_INLINE int32_t tStrTokenCompare(SStrToken* left, SStrToken* right)
return (left->type == right->type && left->n == right->n && strncasecmp(left->z, right->z, left->n) == 0) ? 0 : 1; return (left->type == right->type && left->n == right->n && strncasecmp(left->z, right->z, left->n) == 0) ? 0 : 1;
} }
// this function is not used for temporary
int32_t tSqlExprCompare(tSqlExpr *left, tSqlExpr *right) { int32_t tSqlExprCompare(tSqlExpr *left, tSqlExpr *right) {
if ((left == NULL && right) || (left && right == NULL)) { if ((left == NULL && right) || (left && right == NULL) || (left == NULL && right == NULL)) {
return 1; return 1;
} }
......
...@@ -72,7 +72,7 @@ SSchema* tscGetColumnSchemaById(STableMeta* pTableMeta, int16_t colId) { ...@@ -72,7 +72,7 @@ SSchema* tscGetColumnSchemaById(STableMeta* pTableMeta, int16_t colId) {
} }
STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg) { STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg) {
assert(pTableMetaMsg != NULL && pTableMetaMsg->numOfColumns >= 2 && pTableMetaMsg->numOfTags >= 0); assert(pTableMetaMsg != NULL && pTableMetaMsg->numOfColumns >= 2);
int32_t schemaSize = (pTableMetaMsg->numOfColumns + pTableMetaMsg->numOfTags) * sizeof(SSchema); int32_t schemaSize = (pTableMetaMsg->numOfColumns + pTableMetaMsg->numOfTags) * sizeof(SSchema);
STableMeta* pTableMeta = calloc(1, sizeof(STableMeta) + schemaSize); STableMeta* pTableMeta = calloc(1, sizeof(STableMeta) + schemaSize);
......
...@@ -261,7 +261,7 @@ int32_t qRetrieveQueryResultInfo(qinfo_t qinfo, bool* buildRes, void* pRspContex ...@@ -261,7 +261,7 @@ int32_t qRetrieveQueryResultInfo(qinfo_t qinfo, bool* buildRes, void* pRspContex
SQInfo *pQInfo = (SQInfo *)qinfo; SQInfo *pQInfo = (SQInfo *)qinfo;
if (pQInfo == NULL || !isValidQInfo(pQInfo)) { if (pQInfo == NULL || !isValidQInfo(pQInfo)) {
qError("QInfo:0x%"PRIx64" invalid qhandle", pQInfo->qId); qError("QInfo invalid qhandle");
return TSDB_CODE_QRY_INVALID_QHANDLE; return TSDB_CODE_QRY_INVALID_QHANDLE;
} }
......
...@@ -25,7 +25,7 @@ typedef struct { ...@@ -25,7 +25,7 @@ typedef struct {
uint32_t serverIp; uint32_t serverIp;
int16_t port; int16_t port;
int32_t bufferSize; int32_t bufferSize;
void (*processBrokenLink)(int64_t handleId); void (*processBrokenLink)(int64_t handleId, int32_t closedByApp);
int32_t (*processIncomingMsg)(int64_t handleId, void *buffer); int32_t (*processIncomingMsg)(int64_t handleId, void *buffer);
void (*processIncomingConn)(SOCKET fd, uint32_t ip); void (*processIncomingConn)(SOCKET fd, uint32_t ip);
} SPoolInfo; } SPoolInfo;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
extern void syncProcessTestMsg(SSyncMsg *pMsg, SOCKET connFd); extern void syncProcessTestMsg(SSyncMsg *pMsg, SOCKET connFd);
static void arbSignalHandler(int32_t signum, void *sigInfo, void *context); static void arbSignalHandler(int32_t signum, void *sigInfo, void *context);
static void arbProcessIncommingConnection(SOCKET connFd, uint32_t sourceIp); static void arbProcessIncommingConnection(SOCKET connFd, uint32_t sourceIp);
static void arbProcessBrokenLink(int64_t rid); static void arbProcessBrokenLink(int64_t rid, int32_t closedByApp);
static int32_t arbProcessPeerMsg(int64_t rid, void *buffer); static int32_t arbProcessPeerMsg(int64_t rid, void *buffer);
static tsem_t tsArbSem; static tsem_t tsArbSem;
static void * tsArbTcpPool; static void * tsArbTcpPool;
...@@ -147,10 +147,10 @@ static void arbProcessIncommingConnection(SOCKET connFd, uint32_t sourceIp) { ...@@ -147,10 +147,10 @@ static void arbProcessIncommingConnection(SOCKET connFd, uint32_t sourceIp) {
return; return;
} }
static void arbProcessBrokenLink(int64_t rid) { static void arbProcessBrokenLink(int64_t rid, int32_t closedByApp) {
SNodeConn *pNode = (SNodeConn *)rid; SNodeConn *pNode = (SNodeConn *)rid;
sDebug("%s, TCP link is broken since %s, close connection", pNode->id, strerror(errno)); sDebug("%s, TCP link is broken since %s, closedByApp:%d", pNode->id, strerror(errno), closedByApp);
tfree(pNode); tfree(pNode);
} }
......
...@@ -43,7 +43,7 @@ static void syncProcessSyncRequest(char *pMsg, SSyncPeer *pPeer); ...@@ -43,7 +43,7 @@ static void syncProcessSyncRequest(char *pMsg, SSyncPeer *pPeer);
static void syncRecoverFromMaster(SSyncPeer *pPeer); static void syncRecoverFromMaster(SSyncPeer *pPeer);
static void syncCheckPeerConnection(void *param, void *tmrId); static void syncCheckPeerConnection(void *param, void *tmrId);
static int32_t syncSendPeersStatusMsgToPeer(SSyncPeer *pPeer, char ack, int8_t type, uint16_t tranId); static int32_t syncSendPeersStatusMsgToPeer(SSyncPeer *pPeer, char ack, int8_t type, uint16_t tranId);
static void syncProcessBrokenLink(int64_t rid); static void syncProcessBrokenLink(int64_t rid, int32_t closedByApp);
static int32_t syncProcessPeerMsg(int64_t rid, void *buffer); static int32_t syncProcessPeerMsg(int64_t rid, void *buffer);
static void syncProcessIncommingConnection(SOCKET connFd, uint32_t sourceIp); static void syncProcessIncommingConnection(SOCKET connFd, uint32_t sourceIp);
static void syncRemovePeer(SSyncPeer *pPeer); static void syncRemovePeer(SSyncPeer *pPeer);
...@@ -1308,7 +1308,7 @@ static void syncProcessIncommingConnection(SOCKET connFd, uint32_t sourceIp) { ...@@ -1308,7 +1308,7 @@ static void syncProcessIncommingConnection(SOCKET connFd, uint32_t sourceIp) {
pthread_mutex_unlock(&pNode->mutex); pthread_mutex_unlock(&pNode->mutex);
} }
static void syncProcessBrokenLink(int64_t rid) { static void syncProcessBrokenLink(int64_t rid, int32_t closedByApp) {
SSyncPeer *pPeer = syncAcquirePeer(rid); SSyncPeer *pPeer = syncAcquirePeer(rid);
if (pPeer == NULL) return; if (pPeer == NULL) return;
...@@ -1316,9 +1316,10 @@ static void syncProcessBrokenLink(int64_t rid) { ...@@ -1316,9 +1316,10 @@ static void syncProcessBrokenLink(int64_t rid) {
pthread_mutex_lock(&pNode->mutex); pthread_mutex_lock(&pNode->mutex);
sDebug("%s, TCP link is broken since %s, pfd:%d sfd:%d", pPeer->id, strerror(errno), pPeer->peerFd, pPeer->syncFd); sDebug("%s, TCP link is broken since %s, pfd:%d sfd:%d closedByApp:%d",
pPeer->id, strerror(errno), pPeer->peerFd, pPeer->syncFd, closedByApp);
pPeer->peerFd = -1; pPeer->peerFd = -1;
if (pPeer->isArb) { if (!closedByApp && pPeer->isArb) {
tsArbOnline = 0; tsArbOnline = 0;
} }
......
...@@ -177,7 +177,7 @@ static void taosProcessBrokenLink(SConnObj *pConn) { ...@@ -177,7 +177,7 @@ static void taosProcessBrokenLink(SConnObj *pConn) {
SPoolInfo * pInfo = &pPool->info; SPoolInfo * pInfo = &pPool->info;
if (pConn->closedByApp == 0) shutdown(pConn->fd, SHUT_WR); if (pConn->closedByApp == 0) shutdown(pConn->fd, SHUT_WR);
(*pInfo->processBrokenLink)(pConn->handleId); (*pInfo->processBrokenLink)(pConn->handleId, pConn->closedByApp);
pThread->numOfFds--; pThread->numOfFds--;
epoll_ctl(pThread->pollFd, EPOLL_CTL_DEL, pConn->fd, NULL); epoll_ctl(pThread->pollFd, EPOLL_CTL_DEL, pConn->fd, NULL);
......
...@@ -486,6 +486,10 @@ static STsdbQueryHandle* tsdbQueryTablesImpl(STsdbRepo* tsdb, STsdbQueryCond* pC ...@@ -486,6 +486,10 @@ static STsdbQueryHandle* tsdbQueryTablesImpl(STsdbRepo* tsdb, STsdbQueryCond* pC
TsdbQueryHandleT* tsdbQueryTables(STsdbRepo* tsdb, STsdbQueryCond* pCond, STableGroupInfo* groupList, uint64_t qId, SMemRef* pRef) { TsdbQueryHandleT* tsdbQueryTables(STsdbRepo* tsdb, STsdbQueryCond* pCond, STableGroupInfo* groupList, uint64_t qId, SMemRef* pRef) {
STsdbQueryHandle* pQueryHandle = tsdbQueryTablesImpl(tsdb, pCond, qId, pRef); STsdbQueryHandle* pQueryHandle = tsdbQueryTablesImpl(tsdb, pCond, qId, pRef);
if (pQueryHandle == NULL) {
return NULL;
}
if (emptyQueryTimewindow(pQueryHandle)) { if (emptyQueryTimewindow(pQueryHandle)) {
return (TsdbQueryHandleT*) pQueryHandle; return (TsdbQueryHandleT*) pQueryHandle;
} }
...@@ -596,6 +600,10 @@ TsdbQueryHandleT tsdbQueryLastRow(STsdbRepo *tsdb, STsdbQueryCond *pCond, STable ...@@ -596,6 +600,10 @@ TsdbQueryHandleT tsdbQueryLastRow(STsdbRepo *tsdb, STsdbQueryCond *pCond, STable
} }
STsdbQueryHandle *pQueryHandle = (STsdbQueryHandle*) tsdbQueryTables(tsdb, pCond, groupList, qId, pMemRef); STsdbQueryHandle *pQueryHandle = (STsdbQueryHandle*) tsdbQueryTables(tsdb, pCond, groupList, qId, pMemRef);
if (pQueryHandle == NULL) {
return NULL;
}
int32_t code = checkForCachedLastRow(pQueryHandle, groupList); int32_t code = checkForCachedLastRow(pQueryHandle, groupList);
if (code != TSDB_CODE_SUCCESS) { // set the numOfTables to be 0 if (code != TSDB_CODE_SUCCESS) { // set the numOfTables to be 0
terrno = code; terrno = code;
...@@ -613,6 +621,10 @@ TsdbQueryHandleT tsdbQueryLastRow(STsdbRepo *tsdb, STsdbQueryCond *pCond, STable ...@@ -613,6 +621,10 @@ TsdbQueryHandleT tsdbQueryLastRow(STsdbRepo *tsdb, STsdbQueryCond *pCond, STable
TsdbQueryHandleT tsdbQueryCacheLast(STsdbRepo *tsdb, STsdbQueryCond *pCond, STableGroupInfo *groupList, uint64_t qId, SMemRef* pMemRef) { TsdbQueryHandleT tsdbQueryCacheLast(STsdbRepo *tsdb, STsdbQueryCond *pCond, STableGroupInfo *groupList, uint64_t qId, SMemRef* pMemRef) {
STsdbQueryHandle *pQueryHandle = (STsdbQueryHandle*) tsdbQueryTables(tsdb, pCond, groupList, qId, pMemRef); STsdbQueryHandle *pQueryHandle = (STsdbQueryHandle*) tsdbQueryTables(tsdb, pCond, groupList, qId, pMemRef);
if (pQueryHandle == NULL) {
return NULL;
}
int32_t code = checkForCachedLast(pQueryHandle); int32_t code = checkForCachedLast(pQueryHandle);
if (code != TSDB_CODE_SUCCESS) { // set the numOfTables to be 0 if (code != TSDB_CODE_SUCCESS) { // set the numOfTables to be 0
terrno = code; terrno = code;
......
...@@ -44,7 +44,7 @@ typedef struct { ...@@ -44,7 +44,7 @@ typedef struct {
#define listNEles(l) (l)->numOfEles #define listNEles(l) (l)->numOfEles
#define listEleSize(l) (l)->eleSize #define listEleSize(l) (l)->eleSize
#define isListEmpty(l) ((l)->numOfEles == 0) #define isListEmpty(l) ((l)->numOfEles == 0)
#define listNodeFree(n) free(n); #define listNodeFree(n) free(n)
SList * tdListNew(int eleSize); SList * tdListNew(int eleSize);
void * tdListFree(SList *list); void * tdListFree(SList *list);
......
...@@ -480,6 +480,10 @@ int tsCompressTimestampImp(const char *const input, const int nelements, char *c ...@@ -480,6 +480,10 @@ int tsCompressTimestampImp(const char *const input, const int nelements, char *c
int64_t *istream = (int64_t *)input; int64_t *istream = (int64_t *)input;
int64_t prev_value = istream[0]; int64_t prev_value = istream[0];
if(prev_value >= 0x8000000000000000) {
uWarn("compression timestamp is over signed long long range. ts = 0x%"PRIx64" \n", prev_value);
goto _exit_over;
}
int64_t prev_delta = -prev_value; int64_t prev_delta = -prev_value;
uint8_t flags = 0, flag1 = 0, flag2 = 0; uint8_t flags = 0, flag1 = 0, flag2 = 0;
uint64_t dd1 = 0, dd2 = 0; uint64_t dd1 = 0, dd2 = 0;
......
...@@ -110,7 +110,9 @@ void vnodeRelease(void *vparam) { ...@@ -110,7 +110,9 @@ void vnodeRelease(void *vparam) {
if (vparam == NULL) return; if (vparam == NULL) return;
int32_t refCount = atomic_sub_fetch_32(&pVnode->refCount, 1); int32_t refCount = atomic_sub_fetch_32(&pVnode->refCount, 1);
vTrace("vgId:%d, release vnode, refCount:%d pVnode:%p", pVnode->vgId, refCount, pVnode); int32_t vgId = pVnode->vgId;
vTrace("vgId:%d, release vnode, refCount:%d pVnode:%p", vgId, refCount, pVnode);
assert(refCount >= 0); assert(refCount >= 0);
if (refCount > 0) { if (refCount > 0) {
...@@ -118,10 +120,10 @@ void vnodeRelease(void *vparam) { ...@@ -118,10 +120,10 @@ void vnodeRelease(void *vparam) {
tsem_post(&pVnode->sem); tsem_post(&pVnode->sem);
} }
} else { } else {
vDebug("vgId:%d, vnode will be destroyed, refCount:%d pVnode:%p", pVnode->vgId, refCount, pVnode); vDebug("vgId:%d, vnode will be destroyed, refCount:%d pVnode:%p", vgId, refCount, pVnode);
vnodeDestroyInMWorker(pVnode); vnodeDestroyInMWorker(pVnode);
int32_t count = taosHashGetSize(tsVnodesHash); int32_t count = taosHashGetSize(tsVnodesHash);
vDebug("vgId:%d, vnode is destroyed, vnodes:%d", pVnode->vgId, count); vDebug("vgId:%d, vnode is destroyed, vnodes:%d", vgId, count);
} }
} }
......
...@@ -18,7 +18,7 @@ def pre_test(){ ...@@ -18,7 +18,7 @@ def pre_test(){
rm -rf ${WK}/debug rm -rf ${WK}/debug
mkdir debug mkdir debug
cd debug cd debug
cmake -DMEMORY_SANITIZER=true .. > /dev/null cmake .. > /dev/null
make > /dev/null make > /dev/null
make install > /dev/null make install > /dev/null
pip3 install ${WKC}/src/connector/python pip3 install ${WKC}/src/connector/python
...@@ -155,7 +155,7 @@ pipeline { ...@@ -155,7 +155,7 @@ pipeline {
''' '''
} }
sh ''' sh '''
pkill -9 taosd pkill -9 taosd || echo 1
cd ${WKC}/tests cd ${WKC}/tests
./test-all.sh b2 ./test-all.sh b2
date date
......
...@@ -33,7 +33,7 @@ namespace TDengineDriver ...@@ -33,7 +33,7 @@ namespace TDengineDriver
//sql parameters //sql parameters
private string dbName; private string dbName;
private string tbName; private string tbName;
private string precision;
private bool isInsertData; private bool isInsertData;
private bool isQueryData; private bool isQueryData;
...@@ -61,9 +61,9 @@ namespace TDengineDriver ...@@ -61,9 +61,9 @@ namespace TDengineDriver
tester.checkInsert(); tester.checkInsert();
tester.checkSelect(); tester.checkSelect();
tester.checkDropTable(); tester.checkDropTable();
tester.dropDatabase();
tester.CloseConnection(); tester.CloseConnection();
tester.cleanup();
} }
...@@ -156,7 +156,9 @@ namespace TDengineDriver ...@@ -156,7 +156,9 @@ namespace TDengineDriver
Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "How many rows to insert, default is 100"); 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}", indent, "-c");
Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Configuration directory"); Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Configuration directory");
//
Console.WriteLine("{0:G}{1:G}", indent, "-ps");
Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Configurate db precision,default millisecond");
ExitProgram(); ExitProgram();
} }
} }
...@@ -168,9 +170,9 @@ namespace TDengineDriver ...@@ -168,9 +170,9 @@ namespace TDengineDriver
host = this.GetArgumentAsString(argv, "-h", "127.0.0.1"); host = this.GetArgumentAsString(argv, "-h", "127.0.0.1");
user = this.GetArgumentAsString(argv, "-u", "root"); user = this.GetArgumentAsString(argv, "-u", "root");
password = this.GetArgumentAsString(argv, "-p", "taosdata"); password = this.GetArgumentAsString(argv, "-p", "taosdata");
dbName = this.GetArgumentAsString(argv, "-db", "test"); dbName = this.GetArgumentAsString(argv, "-d", "test");
tbName = this.GetArgumentAsString(argv, "-s", "weather"); tbName = this.GetArgumentAsString(argv, "-s", "weather");
precision = this.GetArgumentAsString(argv, "-ps", "ms");
isInsertData = this.GetArgumentAsLong(argv, "-w", 0, 1, 1) != 0; isInsertData = this.GetArgumentAsLong(argv, "-w", 0, 1, 1) != 0;
isQueryData = this.GetArgumentAsLong(argv, "-r", 0, 1, 1) != 0; isQueryData = this.GetArgumentAsLong(argv, "-r", 0, 1, 1) != 0;
tableCount = this.GetArgumentAsLong(argv, "-n", 1, 10000, 10); tableCount = this.GetArgumentAsLong(argv, "-n", 1, 10000, 10);
...@@ -183,6 +185,7 @@ namespace TDengineDriver ...@@ -183,6 +185,7 @@ namespace TDengineDriver
{ {
TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, this.configDir); TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, this.configDir);
TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60"); TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60");
Console.WriteLine("init...");
TDengine.Init(); TDengine.Init();
Console.WriteLine("get connection starting..."); Console.WriteLine("get connection starting...");
} }
...@@ -204,7 +207,7 @@ namespace TDengineDriver ...@@ -204,7 +207,7 @@ namespace TDengineDriver
public void createDatabase() public void createDatabase()
{ {
StringBuilder sql = new StringBuilder(); StringBuilder sql = new StringBuilder();
sql.Append("create database if not exists ").Append(this.dbName); sql.Append("create database if not exists ").Append(this.dbName).Append(" precision '").Append(this.precision).Append("'");
execute(sql.ToString()); execute(sql.ToString());
} }
public void useDatabase() public void useDatabase()
...@@ -216,8 +219,8 @@ namespace TDengineDriver ...@@ -216,8 +219,8 @@ namespace TDengineDriver
public void checkSelect() public void checkSelect()
{ {
StringBuilder sql = new StringBuilder(); StringBuilder sql = new StringBuilder();
sql.Append("select * from test.weather"); sql.Append("select * from ").Append(this.dbName).Append(".").Append(this.tbName);
execute(sql.ToString()); ExecuteQuery(sql.ToString());
} }
public void createTable() public void createTable()
{ {
...@@ -228,7 +231,7 @@ namespace TDengineDriver ...@@ -228,7 +231,7 @@ namespace TDengineDriver
public void checkInsert() public void checkInsert()
{ {
StringBuilder sql = new StringBuilder(); StringBuilder sql = new StringBuilder();
sql.Append("insert into test.weather (ts, temperature, humidity) values(now, 20.5, 34)"); sql.Append("insert into ").Append(this.dbName).Append(".").Append(this.tbName).Append("(ts, temperature, humidity) values(now, 20.5, 34)");
execute(sql.ToString()); execute(sql.ToString());
} }
public void checkDropTable() public void checkDropTable()
...@@ -237,6 +240,12 @@ namespace TDengineDriver ...@@ -237,6 +240,12 @@ namespace TDengineDriver
sql.Append("drop table if exists ").Append(this.dbName).Append(".").Append(this.tbName).Append(""); sql.Append("drop table if exists ").Append(this.dbName).Append(".").Append(this.tbName).Append("");
execute(sql.ToString()); execute(sql.ToString());
} }
public void dropDatabase()
{
StringBuilder sql = new StringBuilder();
sql.Append("drop database if exists ").Append(this.dbName);
execute(sql.ToString());
}
public void execute(string sql) public void execute(string sql)
{ {
DateTime dt1 = DateTime.Now; DateTime dt1 = DateTime.Now;
...@@ -266,6 +275,7 @@ namespace TDengineDriver ...@@ -266,6 +275,7 @@ namespace TDengineDriver
DateTime dt1 = DateTime.Now; DateTime dt1 = DateTime.Now;
long queryRows = 0; long queryRows = 0;
IntPtr res = TDengine.Query(conn, sql); IntPtr res = TDengine.Query(conn, sql);
getPrecision(res);
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
{ {
Console.Write(sql.ToString() + " failure, "); Console.Write(sql.ToString() + " failure, ");
...@@ -379,8 +389,31 @@ namespace TDengineDriver ...@@ -379,8 +389,31 @@ namespace TDengineDriver
static void ExitProgram() static void ExitProgram()
{ {
TDengine.Cleanup();
System.Environment.Exit(0); System.Environment.Exit(0);
} }
public void cleanup()
{
Console.WriteLine("clean up...");
System.Environment.Exit(0);
}
// method to get db precision
public void getPrecision(IntPtr res)
{
int psc=TDengine.ResultPrecision(res);
switch(psc)
{
case 0:
Console.WriteLine("db:[{0:G}]'s precision is {1:G}",this.dbName,"millisecond");
break;
case 1:
Console.WriteLine("db:[{0:G}]'s precision is {1:G}",this.dbName,"microsecond");
break;
case 2:
Console.WriteLine("db:[{0:G}]'s precision is {1:G}",this.dbName,"nanosecond");
break;
}
}
} }
} }
...@@ -19,136 +19,153 @@ using System.Runtime.InteropServices; ...@@ -19,136 +19,153 @@ using System.Runtime.InteropServices;
namespace TDengineDriver namespace TDengineDriver
{ {
enum TDengineDataType { enum TDengineDataType
TSDB_DATA_TYPE_NULL = 0, // 1 bytes
TSDB_DATA_TYPE_BOOL = 1, // 1 bytes
TSDB_DATA_TYPE_TINYINT = 2, // 1 bytes
TSDB_DATA_TYPE_SMALLINT = 3, // 2 bytes
TSDB_DATA_TYPE_INT = 4, // 4 bytes
TSDB_DATA_TYPE_BIGINT = 5, // 8 bytes
TSDB_DATA_TYPE_FLOAT = 6, // 4 bytes
TSDB_DATA_TYPE_DOUBLE = 7, // 8 bytes
TSDB_DATA_TYPE_BINARY = 8, // string
TSDB_DATA_TYPE_TIMESTAMP = 9,// 8 bytes
TSDB_DATA_TYPE_NCHAR = 10 // unicode string
}
enum TDengineInitOption
{
TSDB_OPTION_LOCALE = 0,
TSDB_OPTION_CHARSET = 1,
TSDB_OPTION_TIMEZONE = 2,
TDDB_OPTION_CONFIGDIR = 3,
TDDB_OPTION_SHELL_ACTIVITY_TIMER = 4
}
class TDengineMeta
{
public string name;
public short size;
public byte type;
public string TypeName()
{ {
switch ((TDengineDataType)type) TSDB_DATA_TYPE_NULL = 0, // 1 bytes
{ TSDB_DATA_TYPE_BOOL = 1, // 1 bytes
case TDengineDataType.TSDB_DATA_TYPE_BOOL: TSDB_DATA_TYPE_TINYINT = 2, // 1 bytes
return "BOOLEAN"; TSDB_DATA_TYPE_SMALLINT = 3, // 2 bytes
case TDengineDataType.TSDB_DATA_TYPE_TINYINT: TSDB_DATA_TYPE_INT = 4, // 4 bytes
return "BYTE"; TSDB_DATA_TYPE_BIGINT = 5, // 8 bytes
case TDengineDataType.TSDB_DATA_TYPE_SMALLINT: TSDB_DATA_TYPE_FLOAT = 6, // 4 bytes
return "SHORT"; TSDB_DATA_TYPE_DOUBLE = 7, // 8 bytes
case TDengineDataType.TSDB_DATA_TYPE_INT: TSDB_DATA_TYPE_BINARY = 8, // string
return "INT"; TSDB_DATA_TYPE_TIMESTAMP = 9,// 8 bytes
case TDengineDataType.TSDB_DATA_TYPE_BIGINT: TSDB_DATA_TYPE_NCHAR = 10, // unicode string
return "LONG"; TSDB_DATA_TYPE_UTINYINT = 11,// 1 byte
case TDengineDataType.TSDB_DATA_TYPE_FLOAT: TSDB_DATA_TYPE_USMALLINT= 12,// 2 bytes
return "FLOAT"; TSDB_DATA_TYPE_UINT = 13, // 4 bytes
case TDengineDataType.TSDB_DATA_TYPE_DOUBLE: TSDB_DATA_TYPE_UBIGINT= 14 // 8 bytes
return "DOUBLE";
case TDengineDataType.TSDB_DATA_TYPE_BINARY:
return "STRING";
case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP:
return "TIMESTAMP";
case TDengineDataType.TSDB_DATA_TYPE_NCHAR:
return "NCHAR";
default:
return "undefine";
}
} }
}
class TDengine enum TDengineInitOption
{ {
public const int TSDB_CODE_SUCCESS = 0; TSDB_OPTION_LOCALE = 0,
TSDB_OPTION_CHARSET = 1,
TSDB_OPTION_TIMEZONE = 2,
TDDB_OPTION_CONFIGDIR = 3,
TDDB_OPTION_SHELL_ACTIVITY_TIMER = 4
}
[DllImport("taos.dll", EntryPoint = "taos_init", CallingConvention = CallingConvention.Cdecl)] class TDengineMeta
static extern public void Init(); {
public string name;
public short size;
public byte type;
public string TypeName()
{
switch ((TDengineDataType)type)
{
case TDengineDataType.TSDB_DATA_TYPE_BOOL:
return "BOOL";
case TDengineDataType.TSDB_DATA_TYPE_TINYINT:
return "TINYINT";
case TDengineDataType.TSDB_DATA_TYPE_SMALLINT:
return "SMALLINT";
case TDengineDataType.TSDB_DATA_TYPE_INT:
return "INT";
case TDengineDataType.TSDB_DATA_TYPE_BIGINT:
return "BIGINT";
case TDengineDataType.TSDB_DATA_TYPE_UTINYINT:
return "TINYINT UNSIGNED";
case TDengineDataType.TSDB_DATA_TYPE_USMALLINT:
return "SMALLINT UNSIGNED";
case TDengineDataType.TSDB_DATA_TYPE_UINT:
return "INT UNSIGNED";
case TDengineDataType.TSDB_DATA_TYPE_UBIGINT:
return "BIGINT UNSIGNED";
case TDengineDataType.TSDB_DATA_TYPE_FLOAT:
return "FLOAT";
case TDengineDataType.TSDB_DATA_TYPE_DOUBLE:
return "DOUBLE";
case TDengineDataType.TSDB_DATA_TYPE_BINARY:
return "STRING";
case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP:
return "TIMESTAMP";
case TDengineDataType.TSDB_DATA_TYPE_NCHAR:
return "NCHAR";
default:
return "undefine";
}
}
}
[DllImport("taos.dll", EntryPoint = "taos_cleanup", CallingConvention = CallingConvention.Cdecl)] class TDengine
static extern public void Cleanup(); {
public const int TSDB_CODE_SUCCESS = 0;
[DllImport("taos.dll", EntryPoint = "taos_options", CallingConvention = CallingConvention.Cdecl)] [DllImport("taos", EntryPoint = "taos_init", CallingConvention = CallingConvention.Cdecl)]
static extern public void Options(int option, string value); static extern public void Init();
[DllImport("taos.dll", EntryPoint = "taos_connect", CallingConvention = CallingConvention.Cdecl)] [DllImport("taos", EntryPoint = "taos_cleanup", CallingConvention = CallingConvention.Cdecl)]
static extern public IntPtr Connect(string ip, string user, string password, string db, short port); static extern public void Cleanup();
[DllImport("taos.dll", EntryPoint = "taos_errstr", CallingConvention = CallingConvention.Cdecl)] [DllImport("taos", EntryPoint = "taos_options", CallingConvention = CallingConvention.Cdecl)]
static extern private IntPtr taos_errstr(IntPtr res); static extern public void Options(int option, string value);
static public string Error(IntPtr res)
{
IntPtr errPtr = taos_errstr(res);
return Marshal.PtrToStringAnsi(errPtr);
}
[DllImport("taos.dll", EntryPoint = "taos_errno", CallingConvention = CallingConvention.Cdecl)] [DllImport("taos", EntryPoint = "taos_connect", CallingConvention = CallingConvention.Cdecl)]
static extern public int ErrorNo(IntPtr res); static extern public IntPtr Connect(string ip, string user, string password, string db, short port);
[DllImport("taos.dll", EntryPoint = "taos_query", CallingConvention = CallingConvention.Cdecl)] [DllImport("taos", EntryPoint = "taos_errstr", CallingConvention = CallingConvention.Cdecl)]
static extern public IntPtr Query(IntPtr conn, string sqlstr); static extern private IntPtr taos_errstr(IntPtr res);
static public string Error(IntPtr res)
{
IntPtr errPtr = taos_errstr(res);
return Marshal.PtrToStringAnsi(errPtr);
}
[DllImport("taos.dll", EntryPoint = "taos_affected_rows", CallingConvention = CallingConvention.Cdecl)] [DllImport("taos", EntryPoint = "taos_errno", CallingConvention = CallingConvention.Cdecl)]
static extern public int AffectRows(IntPtr res); static extern public int ErrorNo(IntPtr res);
[DllImport("taos.dll", EntryPoint = "taos_field_count", CallingConvention = CallingConvention.Cdecl)] [DllImport("taos", EntryPoint = "taos_query", CallingConvention = CallingConvention.Cdecl)]
static extern public int FieldCount(IntPtr res); static extern public IntPtr Query(IntPtr conn, string sqlstr);
[DllImport("taos.dll", EntryPoint = "taos_fetch_fields", CallingConvention = CallingConvention.Cdecl)] [DllImport("taos", EntryPoint = "taos_affected_rows", CallingConvention = CallingConvention.Cdecl)]
static extern private IntPtr taos_fetch_fields(IntPtr res); static extern public int AffectRows(IntPtr res);
static public List<TDengineMeta> FetchFields(IntPtr res)
{
const int fieldSize = 68;
List<TDengineMeta> metas = new List<TDengineMeta>();
if (res == IntPtr.Zero)
{
return metas;
}
int fieldCount = FieldCount(res);
IntPtr fieldsPtr = taos_fetch_fields(res);
for (int i = 0; i < fieldCount; ++i)
{
int offset = i * fieldSize;
TDengineMeta meta = new TDengineMeta();
meta.name = Marshal.PtrToStringAnsi(fieldsPtr + offset);
meta.type = Marshal.ReadByte(fieldsPtr + offset + 65);
meta.size = Marshal.ReadInt16(fieldsPtr + offset + 66);
metas.Add(meta);
}
return metas;
}
[DllImport("taos.dll", EntryPoint = "taos_fetch_row", CallingConvention = CallingConvention.Cdecl)] [DllImport("taos", EntryPoint = "taos_field_count", CallingConvention = CallingConvention.Cdecl)]
static extern public IntPtr FetchRows(IntPtr res); static extern public int FieldCount(IntPtr res);
[DllImport("taos.dll", EntryPoint = "taos_free_result", CallingConvention = CallingConvention.Cdecl)] [DllImport("taos", EntryPoint = "taos_fetch_fields", CallingConvention = CallingConvention.Cdecl)]
static extern public IntPtr FreeResult(IntPtr res); static extern private IntPtr taos_fetch_fields(IntPtr res);
static public List<TDengineMeta> FetchFields(IntPtr res)
{
const int fieldSize = 68;
[DllImport("taos.dll", EntryPoint = "taos_close", CallingConvention = CallingConvention.Cdecl)] List<TDengineMeta> metas = new List<TDengineMeta>();
static extern public int Close(IntPtr taos); if (res == IntPtr.Zero)
} {
} return metas;
\ No newline at end of file }
int fieldCount = FieldCount(res);
IntPtr fieldsPtr = taos_fetch_fields(res);
for (int i = 0; i < fieldCount; ++i)
{
int offset = i * fieldSize;
TDengineMeta meta = new TDengineMeta();
meta.name = Marshal.PtrToStringAnsi(fieldsPtr + offset);
meta.type = Marshal.ReadByte(fieldsPtr + offset + 65);
meta.size = Marshal.ReadInt16(fieldsPtr + offset + 66);
metas.Add(meta);
}
return metas;
}
[DllImport("taos", EntryPoint = "taos_fetch_row", CallingConvention = CallingConvention.Cdecl)]
static extern public IntPtr FetchRows(IntPtr res);
[DllImport("taos", EntryPoint = "taos_free_result", CallingConvention = CallingConvention.Cdecl)]
static extern public IntPtr FreeResult(IntPtr res);
[DllImport("taos", EntryPoint = "taos_close", CallingConvention = CallingConvention.Cdecl)]
static extern public int Close(IntPtr taos);
//get precisionin parameter restultset
[DllImport("taos", EntryPoint = "taos_result_precision", CallingConvention = CallingConvention.Cdecl)]
static extern public int ResultPrecision(IntPtr taos);
}
}
...@@ -163,5 +163,9 @@ namespace TDengineDriver ...@@ -163,5 +163,9 @@ namespace TDengineDriver
[DllImport("taos", EntryPoint = "taos_close", CallingConvention = CallingConvention.Cdecl)] [DllImport("taos", EntryPoint = "taos_close", CallingConvention = CallingConvention.Cdecl)]
static extern public int Close(IntPtr taos); static extern public int Close(IntPtr taos);
//get precisionin parameter restultset
[DllImport("taos", EntryPoint = "taos_result_precision", CallingConvention = CallingConvention.Cdecl)]
static extern public int ResultPrecision(IntPtr taos);
} }
} }
...@@ -163,5 +163,8 @@ namespace TDengineDriver ...@@ -163,5 +163,8 @@ namespace TDengineDriver
[DllImport("taos", EntryPoint = "taos_close", CallingConvention = CallingConvention.Cdecl)] [DllImport("taos", EntryPoint = "taos_close", CallingConvention = CallingConvention.Cdecl)]
static extern public int Close(IntPtr taos); static extern public int Close(IntPtr taos);
//get precisionin parameter restultset
[DllImport("taos", EntryPoint = "taos_result_precision", CallingConvention = CallingConvention.Cdecl)]
static extern public int ResultPrecision(IntPtr taos);
} }
} }
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<dependency> <dependency>
<groupId>com.taosdata.jdbc</groupId> <groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId> <artifactId>taos-jdbcdriver</artifactId>
<version>2.0.30</version> <version>2.0.31</version>
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -43,6 +43,7 @@ public class JdbcDemo { ...@@ -43,6 +43,7 @@ public class JdbcDemo {
if (connection != null) if (connection != null)
System.out.println("[ OK ] Connection established."); System.out.println("[ OK ] Connection established.");
} catch (ClassNotFoundException | SQLException e) { } catch (ClassNotFoundException | SQLException e) {
System.out.println("[ ERROR! ] Connection establish failed.");
e.printStackTrace(); e.printStackTrace();
} }
} }
...@@ -68,7 +69,7 @@ public class JdbcDemo { ...@@ -68,7 +69,7 @@ public class JdbcDemo {
} }
private void insert() { private void insert() {
final String sql = "insert into " + dbName + "." + tbName + " (ts, temperature, humidity) values(now, 20.5, 34)"; final String sql = "insert into " + dbName + "." + tbName + " (ts, temperature, humidity) values(now, 20.5, 34)";
exuete(sql); exuete(sql);
} }
...@@ -91,13 +92,15 @@ public class JdbcDemo { ...@@ -91,13 +92,15 @@ public class JdbcDemo {
/************************************************************************/ /************************************************************************/
private void executeQuery(String sql) { private void executeQuery(String sql) {
long start = System.currentTimeMillis();
try (Statement statement = connection.createStatement()) { try (Statement statement = connection.createStatement()) {
long start = System.currentTimeMillis();
ResultSet resultSet = statement.executeQuery(sql); ResultSet resultSet = statement.executeQuery(sql);
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
printSql(sql, true, (end - start)); printSql(sql, true, (end - start));
printResult(resultSet); printResult(resultSet);
} catch (SQLException e) { } catch (SQLException e) {
long end = System.currentTimeMillis();
printSql(sql, false, (end - start));
e.printStackTrace(); e.printStackTrace();
} }
} }
...@@ -120,12 +123,14 @@ public class JdbcDemo { ...@@ -120,12 +123,14 @@ public class JdbcDemo {
} }
private void exuete(String sql) { private void exuete(String sql) {
long start = System.currentTimeMillis();
try (Statement statement = connection.createStatement()) { try (Statement statement = connection.createStatement()) {
long start = System.currentTimeMillis();
boolean execute = statement.execute(sql); boolean execute = statement.execute(sql);
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
printSql(sql, execute, (end - start)); printSql(sql, true, (end - start));
} catch (SQLException e) { } catch (SQLException e) {
long end = System.currentTimeMillis();
printSql(sql, false, (end - start));
e.printStackTrace(); e.printStackTrace();
} }
...@@ -137,4 +142,4 @@ public class JdbcDemo { ...@@ -137,4 +142,4 @@ public class JdbcDemo {
} }
} }
\ No newline at end of file
...@@ -18,7 +18,7 @@ def pre_test(){ ...@@ -18,7 +18,7 @@ def pre_test(){
rm -rf ${WK}/debug rm -rf ${WK}/debug
mkdir debug mkdir debug
cd debug cd debug
cmake -DMEMORY_SANITIZER=true .. > /dev/null cmake .. > /dev/null
make > /dev/null make > /dev/null
make install > /dev/null make install > /dev/null
pip3 install ${WKC}/src/connector/python/ || echo 0 pip3 install ${WKC}/src/connector/python/ || echo 0
...@@ -163,7 +163,7 @@ pipeline { ...@@ -163,7 +163,7 @@ pipeline {
''' '''
} }
sh ''' sh '''
pkill -9 taosd pkill -9 taosd || echo 1
cd ${WKC}/tests cd ${WKC}/tests
./test-all.sh b2 ./test-all.sh b2
date date
......
...@@ -244,6 +244,7 @@ python3 ./test.py -f query/queryStddevWithGroupby.py ...@@ -244,6 +244,7 @@ python3 ./test.py -f query/queryStddevWithGroupby.py
python3 ./test.py -f query/querySecondtscolumnTowherenow.py python3 ./test.py -f query/querySecondtscolumnTowherenow.py
python3 ./test.py -f query/queryFilterTswithDateUnit.py python3 ./test.py -f query/queryFilterTswithDateUnit.py
python3 ./test.py -f query/queryTscomputWithNow.py python3 ./test.py -f query/queryTscomputWithNow.py
python3 ./test.py -f query/queryStableJoin.py
python3 ./test.py -f query/computeErrorinWhere.py python3 ./test.py -f query/computeErrorinWhere.py
python3 ./test.py -f query/queryTsisNull.py python3 ./test.py -f query/queryTsisNull.py
python3 ./test.py -f query/subqueryFilter.py python3 ./test.py -f query/subqueryFilter.py
......
...@@ -73,6 +73,52 @@ class TDTestCase: ...@@ -73,6 +73,52 @@ class TDTestCase:
tdSql.checkData(6, 0, "2020-09-16 00:00:00") tdSql.checkData(6, 0, "2020-09-16 00:00:00")
tdSql.checkData(6, 1, 222.0) tdSql.checkData(6, 1, 222.0)
# test case for https://jira.taosdata.com:18080/browse/TD-5338
tdSql.query("select loc,max(voltage) from st interval(1m);")
tdSql.checkRows(8)
tdSql.checkData(0, 0, "2020-07-01 04:24:00.000")
tdSql.checkData(0, 1, "beijing")
tdSql.checkData(0, 2, 220)
tdSql.checkData(1, 0, "2020-07-12 18:11:00.000")
tdSql.checkData(1, 1, "beijing")
tdSql.checkData(1, 2, 221)
tdSql.checkData(2, 0, "2020-07-24 07:58:00.000")
tdSql.checkData(2, 1, "beijing")
tdSql.checkData(2, 2, 225)
tdSql.checkData(3, 0, "2020-08-04 21:44:00.000")
tdSql.checkData(2, 1, "beijing")
tdSql.checkData(3, 2, 228)
tdSql.checkData(4, 0, "2020-08-16 11:31:00.000")
tdSql.checkData(4, 1, "shanghai")
tdSql.checkData(4, 2, 225)
tdSql.checkData(5, 0, "2020-08-28 01:18:00.000")
tdSql.checkData(5, 1, "shanghai")
tdSql.checkData(5, 2, 228)
tdSql.checkData(6, 0, "2020-09-08 15:04:00.000")
tdSql.checkData(6, 1, "beijing")
tdSql.checkData(6, 2, 222)
tdSql.checkData(7, 0, "2020-09-20 04:51:00.000")
tdSql.checkData(7, 1, "shanghai")
tdSql.checkData(7, 2, 222)
tdSql.query("select loc,max(voltage) from t0 interval(1m);")
tdSql.checkRows(5)
tdSql.checkData(0, 0, "2020-07-01 04:24:00.000")
tdSql.checkData(0, 1, "beijing")
tdSql.checkData(0, 2, 220)
tdSql.checkData(1, 0, "2020-07-12 18:11:00.000")
tdSql.checkData(1, 1, "beijing")
tdSql.checkData(1, 2, 221)
tdSql.checkData(2, 0, "2020-07-24 07:58:00.000")
tdSql.checkData(2, 1, "beijing")
tdSql.checkData(2, 2, 225)
tdSql.checkData(3, 0, "2020-08-04 21:44:00.000")
tdSql.checkData(2, 1, "beijing")
tdSql.checkData(3, 2, 228)
tdSql.checkData(4, 0, "2020-09-08 15:04:00.000")
tdSql.checkData(4, 1, "beijing")
tdSql.checkData(4, 2, 222)
# test case for https://jira.taosdata.com:18080/browse/TD-2298 # test case for https://jira.taosdata.com:18080/browse/TD-2298
tdSql.execute("create database test keep 36500") tdSql.execute("create database test keep 36500")
tdSql.execute("use test") tdSql.execute("use test")
......
###################################################################
# 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
import taos
from util.log import tdLog
from util.cases import tdCases
from util.sql import tdSql
import random
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self.ts = 1600000000000
self.num = 10
def run(self):
tdSql.prepare()
# test case for https://jira.taosdata.com:18080/browse/TD-5206
tdSql.execute('''create stable stable_1
(ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint,
q_bool bool , q_binary binary(20) , q_nchar nchar(20) ,q_float float , q_double double , q_ts timestamp)
tags(loc nchar(20) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint,
t_bool bool , t_binary binary(20) , t_nchar nchar(20) ,t_float float , t_double double );''')
tdSql.execute('''create stable stable_2
(ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint,
q_bool bool , q_binary binary(20) , q_nchar nchar(20) ,q_float float , q_double double , q_ts timestamp)
tags(loc nchar(20) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint,
t_bool bool , t_binary binary(20) , t_nchar nchar(20) ,t_float float , t_double double );''')
tdSql.execute('''create table table_0 using stable_1
tags('table_0' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' )''')
tdSql.execute('''create table table_1 using stable_1
tags('table_1' , '2147483647' , '9223372036854775807' , '32767' , '127' , 1 ,
'binary1' , 'nchar1' , '1' , '11' )''')
tdSql.execute('''create table table_2 using stable_1
tags('table_2' , '-2147483647' , '-9223372036854775807' , '-32767' , '-127' , false ,
'binary2' , 'nchar2nchar2' , '-2.2' , '-22.22')''')
tdSql.execute('''create table table_3 using stable_1
tags('table_3' , '3' , '3' , '3' , '3' , true , 'binary3' , 'nchar3' , '33.33' , '3333.3333' )''')
tdSql.execute('''create table table_4 using stable_1
tags('table_4' , '4' , '4' , '4' , '4' , false , 'binary4' , 'nchar4' , '-444.444' , '-444444.444444' )''')
tdSql.execute('''create table table_5 using stable_1
tags('table_5' , '5' , '5' , '5' , '5' , true , 'binary5' , 'nchar5' , '5555.5555' , '55555555.55555555' )''')
tdSql.execute('''create table table_21 using stable_2
tags('table_5' , '5' , '5' , '5' , '5' , true , 'binary5' , 'nchar5' , '5555.5555' , '55555555.55555555' )''')
for i in range(self.num):
tdSql.execute('''insert into table_0 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)'''
% (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i))
tdSql.execute('''insert into table_1 values(%d, %d, %d, %d, %d, 1, 'binary1.%s', 'nchar1.%s', %f, %f, %d)'''
% (self.ts + i, 2147483647-i, 9223372036854775807-i, 32767-i, 127-i,
i, i, random.random(), random.random(), 1262304000001 + i))
tdSql.execute('''insert into table_2 values(%d, %d, %d, %d, %d, true, 'binary2.%s', 'nchar2nchar2.%s', %f, %f, %d)'''
% (self.ts + i, -2147483647+i, -9223372036854775807+i, -32767+i, -127+i,
i, i, random.uniform(-1,0), random.uniform(-1,0), 1577836800001 + i))
tdSql.execute('''insert into table_3 values(%d, %d, %d, %d, %d, false, 'binary3.%s', 'nchar3.%s', %f, %f, %d)'''
% (self.ts + i, random.randint(-2147483647, 2147483647),
random.randint(-9223372036854775807, 9223372036854775807), random.randint(-32767, 32767),
random.randint(-127, 127), random.randint(-100, 100), random.randint(-10000, 10000),
random.uniform(-100000,100000), random.uniform(-1000000000,1000000000), self.ts + i))
tdSql.execute('''insert into table_4 values(%d, %d, %d, %d, %d, true, 'binary4.%s', 'nchar4.%s', %f, %f, %d)'''
% (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i))
tdSql.execute('''insert into table_5 values(%d, %d, %d, %d, %d, false, 'binary5.%s', 'nchar5.%s', %f, %f, %d)'''
% (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i))
tdSql.execute('''insert into table_21 values(%d, %d, %d, %d, %d, false, 'binary5.%s', 'nchar5.%s', %f, %f, %d)'''
% (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i))
tdLog.info("==========TEST1:test all table data==========")
sql = '''select * from stable_1,stable_2 where stable_1.t_nchar = stable_2.t_nchar and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_tinyint = stable_2.t_tinyint and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_binary = stable_2.t_binary and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_double = stable_2.t_double and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_smallint = stable_2.t_smallint and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_bigint = stable_2.t_bigint and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_int = stable_2.t_int and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_float = stable_2.t_float and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_bool = stable_2.t_bool and stable_1.ts = stable_2.ts;'''
tdSql.error(sql)
tdLog.info("==========TEST1:test drop table_0 data==========")
sql = '''drop table table_0;'''
tdSql.execute(sql)
sql = '''select * from stable_1,stable_2 where stable_1.t_nchar = stable_2.t_nchar and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_tinyint = stable_2.t_tinyint and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_binary = stable_2.t_binary and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_double = stable_2.t_double and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_smallint = stable_2.t_smallint and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_bigint = stable_2.t_bigint and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_int = stable_2.t_int and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_float = stable_2.t_float and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_bool = stable_2.t_bool and stable_1.ts = stable_2.ts;'''
tdSql.error(sql)
tdLog.info("==========TEST1:test drop table_1 data==========")
sql = '''drop table table_1;'''
tdSql.execute(sql)
sql = '''select * from stable_1,stable_2 where stable_1.t_nchar = stable_2.t_nchar and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_tinyint = stable_2.t_tinyint and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_binary = stable_2.t_binary and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_double = stable_2.t_double and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_smallint = stable_2.t_smallint and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_bigint = stable_2.t_bigint and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_int = stable_2.t_int and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_float = stable_2.t_float and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_bool = stable_2.t_bool and stable_1.ts = stable_2.ts;'''
tdSql.error(sql)
tdLog.info("==========TEST1:test drop table_2 data==========")
sql = '''drop table table_2;'''
tdSql.execute(sql)
sql = '''select * from stable_1,stable_2 where stable_1.t_nchar = stable_2.t_nchar and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_tinyint = stable_2.t_tinyint and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_binary = stable_2.t_binary and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_double = stable_2.t_double and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_smallint = stable_2.t_smallint and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_bigint = stable_2.t_bigint and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_int = stable_2.t_int and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_float = stable_2.t_float and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_bool = stable_2.t_bool and stable_1.ts = stable_2.ts;'''
tdSql.error(sql)
tdLog.info("==========TEST1:test drop table_3 data==========")
sql = '''drop table table_3;'''
tdSql.execute(sql)
sql = '''select * from stable_1,stable_2 where stable_1.t_nchar = stable_2.t_nchar and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_tinyint = stable_2.t_tinyint and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_binary = stable_2.t_binary and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_double = stable_2.t_double and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_smallint = stable_2.t_smallint and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_bigint = stable_2.t_bigint and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_int = stable_2.t_int and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_float = stable_2.t_float and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_bool = stable_2.t_bool and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
tdLog.info("==========TEST1:test drop table_4 data==========")
sql = '''drop table table_4;'''
tdSql.execute(sql)
sql = '''select * from stable_1,stable_2 where stable_1.t_nchar = stable_2.t_nchar and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_tinyint = stable_2.t_tinyint and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_binary = stable_2.t_binary and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_double = stable_2.t_double and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_smallint = stable_2.t_smallint and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_bigint = stable_2.t_bigint and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_int = stable_2.t_int and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_float = stable_2.t_float and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
sql = '''select * from stable_1,stable_2 where stable_1.t_bool = stable_2.t_bool and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(self.num)
tdLog.info("==========TEST1:test drop table_5 data==========")
sql = '''drop table table_5;'''
tdSql.execute(sql)
sql = '''select * from stable_1,stable_2 where stable_1.t_nchar = stable_2.t_nchar and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(0)
sql = '''select * from stable_1,stable_2 where stable_1.t_tinyint = stable_2.t_tinyint and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(0)
sql = '''select * from stable_1,stable_2 where stable_1.t_binary = stable_2.t_binary and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(0)
sql = '''select * from stable_1,stable_2 where stable_1.t_double = stable_2.t_double and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(0)
sql = '''select * from stable_1,stable_2 where stable_1.t_smallint = stable_2.t_smallint and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(0)
sql = '''select * from stable_1,stable_2 where stable_1.t_bigint = stable_2.t_bigint and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(0)
sql = '''select * from stable_1,stable_2 where stable_1.t_int = stable_2.t_int and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(0)
sql = '''select * from stable_1,stable_2 where stable_1.t_float = stable_2.t_float and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(0)
sql = '''select * from stable_1,stable_2 where stable_1.t_bool = stable_2.t_bool and stable_1.ts = stable_2.ts;'''
tdSql.query(sql)
tdSql.checkRows(0)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
\ No newline at end of file
...@@ -176,12 +176,8 @@ class TDTestCase: ...@@ -176,12 +176,8 @@ class TDTestCase:
tdSql.checkData(0, 1, 5) tdSql.checkData(0, 1, 5)
tdSql.checkData(1, 1, 6) tdSql.checkData(1, 1, 6)
tdSql.checkData(2, 1, 7) tdSql.checkData(2, 1, 7)
os.system("rm -rf tools/taosdemoAllTest/TD-4985/query-limit-offset.py.sql") os.system("rm -rf tools/taosdemoAllTest/TD-4985/query-limit-offset.py.sql")
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
......
...@@ -180,13 +180,14 @@ class TDTestCase: ...@@ -180,13 +180,14 @@ class TDTestCase:
os.system("%staosdemo -f tools/taosdemoAllTest/insertColumnsAndTagNum4096.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insertColumnsAndTagNum4096.json -y " % binPath)
tdSql.query("select count(*) from db.stb0") tdSql.query("select count(*) from db.stb0")
tdSql.checkData(0, 0, 10000) tdSql.checkData(0, 0, 10000)
tdSql.execute("drop database if exists db") tdSql.execute("drop database if exists db")
os.system("%staosdemo -f tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json -y " % binPath)
tdSql.query("select count(*) from db.stb0") tdSql.query("select count(*) from db.stb0")
tdSql.checkRows(0) tdSql.checkRows(0)
tdSql.execute("drop database if exists db") tdSql.execute("drop database if exists db")
os.system("%staosdemo -f tools/taosdemoAllTest/insertColumnsNum0.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insertColumnsNum0.json -y " % binPath)
tdSql.execute("use db") tdSql.execute("use db")
tdSql.query("show stables like 'stb0%' ") tdSql.query("show stables like 'stb0%' ")
tdSql.checkData(0, 2, 11) tdSql.checkData(0, 2, 11)
tdSql.execute("drop database if exists db") tdSql.execute("drop database if exists db")
...@@ -196,7 +197,7 @@ class TDTestCase: ...@@ -196,7 +197,7 @@ class TDTestCase:
os.system("%staosdemo -f tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar49151.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar49151.json -y " % binPath)
tdSql.query("select count(*) from db.stb0") tdSql.query("select count(*) from db.stb0")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.query("select count(*) from db.stb1") tdSql.query("select count(*) from db.stb1")
tdSql.checkRows(1) tdSql.checkRows(1)
tdSql.error("select * from db.stb4") tdSql.error("select * from db.stb4")
tdSql.error("select * from db.stb2") tdSql.error("select * from db.stb2")
...@@ -221,7 +222,7 @@ class TDTestCase: ...@@ -221,7 +222,7 @@ class TDTestCase:
tdSql.checkData(0, 0, "2020-03-31 12:00:00.000") tdSql.checkData(0, 0, "2020-03-31 12:00:00.000")
tdSql.query("select first(ts) from blf.p_0_topics_2") tdSql.query("select first(ts) from blf.p_0_topics_2")
tdSql.checkData(0, 0, "2019-10-01 00:00:00") tdSql.checkData(0, 0, "2019-10-01 00:00:00")
tdSql.query("select last(ts) from blf.p_0_topics_6 ") tdSql.query("select last(ts) from blf.p_0_topics_6 ")
tdSql.checkData(0, 0, "2020-09-29 23:59:00") tdSql.checkData(0, 0, "2020-09-29 23:59:00")
os.system("%staosdemo -f tools/taosdemoAllTest/insertMaxNumPerReq.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/insertMaxNumPerReq.json -y " % binPath)
tdSql.execute("use db") tdSql.execute("use db")
...@@ -324,6 +325,7 @@ class TDTestCase: ...@@ -324,6 +325,7 @@ class TDTestCase:
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
......
...@@ -98,8 +98,8 @@ class TDTestCase: ...@@ -98,8 +98,8 @@ class TDTestCase:
break break
time.sleep(1) time.sleep(1)
print("alter table test.meters add column col10 int") print("alter table test.meters add column c10 int")
tdSql.execute("alter table test.meters add column col10 int") tdSql.execute("alter table test.meters add column c10 int")
print("insert into test.t9 values (now, 1, 2, 3, 4, 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)") tdSql.execute("insert into test.t9 values (now, 1, 2, 3, 4, 0)")
......
...@@ -28,6 +28,7 @@ class TDTestCase: ...@@ -28,6 +28,7 @@ class TDTestCase:
def restart_taosd(self,db): def restart_taosd(self,db):
tdDnodes.stop(1) tdDnodes.stop(1)
tdDnodes.startWithoutSleep(1) tdDnodes.startWithoutSleep(1)
tdLog.sleep(2)
tdSql.execute("use %s;" % db) tdSql.execute("use %s;" % db)
def date_to_timestamp_microseconds(self, date): def date_to_timestamp_microseconds(self, date):
......
...@@ -783,7 +783,7 @@ endi ...@@ -783,7 +783,7 @@ endi
sql create stable st1 (ts timestamp, f1 int, f2 int) tags (id int); sql create stable st1 (ts timestamp, f1 int, f2 int) tags (id int);
sql create table tb1 using st1 tags(1); sql create table tb1 using st1 tags(1);
sql insert into tb1 values (now, 1, 1); sql insert into tb1 values ('2021-07-02 00:00:00', 1, 1);
sql select stddev(f1) from st1 group by f1; sql select stddev(f1) from st1 group by f1;
......
...@@ -444,6 +444,10 @@ if $rows != $val then ...@@ -444,6 +444,10 @@ if $rows != $val then
return -1 return -1
endi endi
print ================>TD-5600
sql select first(join_tb0.c8),first(join_tb0.c9) from join_tb1 , join_tb0 where join_tb1.ts = join_tb0.ts and join_tb1.ts <= 100002 and join_tb1.ts>=100000 interval(1s) fill(linear);
#=============================================================== #===============================================================
sql select first(join_tb0.c8),first(join_tb0.c9) from join_tb1 , join_tb0 where join_tb1.ts = join_tb0.ts and join_tb1.ts <= 100002 and join_tb0.c7 = true sql select first(join_tb0.c8),first(join_tb0.c9) from join_tb1 , join_tb0 where join_tb1.ts = join_tb0.ts and join_tb1.ts <= 100002 and join_tb0.c7 = true
......
...@@ -34,11 +34,11 @@ while $i < $tbNum ...@@ -34,11 +34,11 @@ while $i < $tbNum
$tb = $tbPrefix . $i $tb = $tbPrefix . $i
sql create table $tb using $mt tags( $i ) sql create table $tb using $mt tags( $i )
$x = -1440 $x = 0
$y = 0 $y = 0
while $y < $rowNum while $y < $rowNum
$ms = $x . m $ts = 1626710400000 + $x
sql insert into $tb values (now $ms , $y , $y ) sql insert into $tb values ($ts , $y , $y )
$x = $x + 1 $x = $x + 1
$y = $y + 1 $y = $y + 1
endw endw
......
...@@ -808,6 +808,11 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) { ...@@ -808,6 +808,11 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
break; break;
case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_BINARY:
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
if (length[i] < 0 || length[i] > 1 << 20) {
fprintf(stderr, "Invalid length(%d) of BINARY or NCHAR\n", length[i]);
exit(-1);
}
memset(value, 0, MAX_QUERY_VALUE_LEN); memset(value, 0, MAX_QUERY_VALUE_LEN);
memcpy(value, row[i], length[i]); memcpy(value, row[i], length[i]);
value[length[i]] = 0; value[length[i]] = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册