提交 a2668155 编写于 作者: sangshuduo's avatar sangshuduo

cherry pick from develop branch.

上级 b9f14871
...@@ -678,7 +678,7 @@ static FILE * g_fpOfInsertResult = NULL; ...@@ -678,7 +678,7 @@ static FILE * g_fpOfInsertResult = NULL;
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
static void ERROR_EXIT(const char *msg) { perror(msg); exit(-1); } static void ERROR_EXIT(const char *msg) { errorPrint("%s", msg); exit(-1); }
#ifndef TAOSDEMO_COMMIT_SHA1 #ifndef TAOSDEMO_COMMIT_SHA1
#define TAOSDEMO_COMMIT_SHA1 "unknown" #define TAOSDEMO_COMMIT_SHA1 "unknown"
...@@ -1140,8 +1140,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { ...@@ -1140,8 +1140,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
} }
if (0 == columnCount) { if (0 == columnCount) {
perror("data type error!"); ERROR_EXIT("data type error!");
exit(-1);
} }
g_args.num_of_CPR = columnCount; g_args.num_of_CPR = columnCount;
...@@ -2429,14 +2428,14 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr, uint16_t port ...@@ -2429,14 +2428,14 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr, uint16_t port
#endif #endif
debugPrint("%s() LN%d, sockfd=%d\n", __func__, __LINE__, sockfd); debugPrint("%s() LN%d, sockfd=%d\n", __func__, __LINE__, sockfd);
free(request_buf); free(request_buf);
ERROR_EXIT("ERROR opening socket"); ERROR_EXIT("opening socket");
} }
int retConn = connect(sockfd, (struct sockaddr *)pServAddr, sizeof(struct sockaddr)); int retConn = connect(sockfd, (struct sockaddr *)pServAddr, sizeof(struct sockaddr));
debugPrint("%s() LN%d connect() return %d\n", __func__, __LINE__, retConn); debugPrint("%s() LN%d connect() return %d\n", __func__, __LINE__, retConn);
if (retConn < 0) { if (retConn < 0) {
free(request_buf); free(request_buf);
ERROR_EXIT("ERROR connecting"); ERROR_EXIT("connecting");
} }
memset(base64_buf, 0, INPUT_BUF_LEN); memset(base64_buf, 0, INPUT_BUF_LEN);
...@@ -2469,7 +2468,7 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr, uint16_t port ...@@ -2469,7 +2468,7 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr, uint16_t port
auth, strlen(sqlstr), sqlstr); auth, strlen(sqlstr), sqlstr);
if (r >= req_buf_len) { if (r >= req_buf_len) {
free(request_buf); free(request_buf);
ERROR_EXIT("ERROR too long request"); ERROR_EXIT("too long request");
} }
verbosePrint("%s() LN%d: Request:\n%s\n", __func__, __LINE__, request_buf); verbosePrint("%s() LN%d: Request:\n%s\n", __func__, __LINE__, request_buf);
...@@ -2482,7 +2481,7 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr, uint16_t port ...@@ -2482,7 +2481,7 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr, uint16_t port
bytes = write(sockfd, request_buf + sent, req_str_len - sent); bytes = write(sockfd, request_buf + sent, req_str_len - sent);
#endif #endif
if (bytes < 0) if (bytes < 0)
ERROR_EXIT("ERROR writing message to socket"); ERROR_EXIT("writing message to socket");
if (bytes == 0) if (bytes == 0)
break; break;
sent+=bytes; sent+=bytes;
...@@ -2499,7 +2498,7 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr, uint16_t port ...@@ -2499,7 +2498,7 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr, uint16_t port
#endif #endif
if (bytes < 0) { if (bytes < 0) {
free(request_buf); free(request_buf);
ERROR_EXIT("ERROR reading response from socket"); ERROR_EXIT("reading response from socket");
} }
if (bytes == 0) if (bytes == 0)
break; break;
...@@ -2508,7 +2507,7 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr, uint16_t port ...@@ -2508,7 +2507,7 @@ static int postProceSql(char *host, struct sockaddr_in *pServAddr, uint16_t port
if (received == resp_len) { if (received == resp_len) {
free(request_buf); free(request_buf);
ERROR_EXIT("ERROR storing complete response from socket"); ERROR_EXIT("storing complete response from socket");
} }
response_buf[RESP_BUF_LEN - 1] = '\0'; response_buf[RESP_BUF_LEN - 1] = '\0';
...@@ -2671,8 +2670,8 @@ static int calcRowLen(SSuperTable* superTbls) { ...@@ -2671,8 +2670,8 @@ static int calcRowLen(SSuperTable* superTbls) {
} else if (strcasecmp(dataType, "TIMESTAMP") == 0) { } else if (strcasecmp(dataType, "TIMESTAMP") == 0) {
lenOfOneRow += TIMESTAMP_BUFF_LEN; lenOfOneRow += TIMESTAMP_BUFF_LEN;
} else { } else {
printf("get error data type : %s\n", dataType); errorPrint("get error data type : %s\n", dataType);
exit(-1); exit(EXIT_FAILURE);
} }
} }
...@@ -2702,8 +2701,8 @@ static int calcRowLen(SSuperTable* superTbls) { ...@@ -2702,8 +2701,8 @@ static int calcRowLen(SSuperTable* superTbls) {
} else if (strcasecmp(dataType, "DOUBLE") == 0) { } else if (strcasecmp(dataType, "DOUBLE") == 0) {
lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + DOUBLE_BUFF_LEN; lenOfTagOfOneRow += superTbls->tags[tagIndex].dataLen + DOUBLE_BUFF_LEN;
} else { } else {
printf("get error tag type : %s\n", dataType); errorPrint("get error tag type : %s\n", dataType);
exit(-1); exit(EXIT_FAILURE);
} }
} }
...@@ -2741,7 +2740,7 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos, ...@@ -2741,7 +2740,7 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
taos_close(taos); taos_close(taos);
errorPrint("%s() LN%d, failed to run command %s\n", errorPrint("%s() LN%d, failed to run command %s\n",
__func__, __LINE__, command); __func__, __LINE__, command);
exit(-1); exit(EXIT_FAILURE);
} }
int64_t childTblCount = (limit < 0)?10000:limit; int64_t childTblCount = (limit < 0)?10000:limit;
...@@ -2752,7 +2751,7 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos, ...@@ -2752,7 +2751,7 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
taos_free_result(res); taos_free_result(res);
taos_close(taos); taos_close(taos);
errorPrint("%s() LN%d, failed to allocate memory!\n", __func__, __LINE__); errorPrint("%s() LN%d, failed to allocate memory!\n", __func__, __LINE__);
exit(-1); exit(EXIT_FAILURE);
} }
} }
...@@ -2763,7 +2762,7 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos, ...@@ -2763,7 +2762,7 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
if (0 == strlen((char *)row[0])) { if (0 == strlen((char *)row[0])) {
errorPrint("%s() LN%d, No.%"PRId64" table return empty name\n", errorPrint("%s() LN%d, No.%"PRId64" table return empty name\n",
__func__, __LINE__, count); __func__, __LINE__, count);
exit(-1); exit(EXIT_FAILURE);
} }
tstrncpy(pTblName, (char *)row[0], len[0]+1); tstrncpy(pTblName, (char *)row[0], len[0]+1);
...@@ -2779,12 +2778,12 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos, ...@@ -2779,12 +2778,12 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos,
(size_t)((childTblCount-count)*TSDB_TABLE_NAME_LEN)); (size_t)((childTblCount-count)*TSDB_TABLE_NAME_LEN));
} else { } else {
// exit, if allocate more memory failed // exit, if allocate more memory failed
errorPrint("%s() LN%d, realloc fail for save child table name of %s.%s\n",
__func__, __LINE__, dbName, sTblName);
tmfree(childTblName); tmfree(childTblName);
taos_free_result(res); taos_free_result(res);
taos_close(taos); taos_close(taos);
exit(-1); errorPrint("%s() LN%d, realloc fail for save child table name of %s.%s\n",
__func__, __LINE__, dbName, sTblName);
exit(EXIT_FAILURE);
} }
} }
pTblName = childTblName + count * TSDB_TABLE_NAME_LEN; pTblName = childTblName + count * TSDB_TABLE_NAME_LEN;
...@@ -2968,7 +2967,7 @@ static int createSuperTable( ...@@ -2968,7 +2967,7 @@ static int createSuperTable(
taos_close(taos); taos_close(taos);
errorPrint("%s() LN%d, config error data type : %s\n", errorPrint("%s() LN%d, config error data type : %s\n",
__func__, __LINE__, dataType); __func__, __LINE__, dataType);
exit(-1); exit(EXIT_FAILURE);
} }
} }
...@@ -2977,10 +2976,10 @@ static int createSuperTable( ...@@ -2977,10 +2976,10 @@ static int createSuperTable(
// save for creating child table // save for creating child table
superTbl->colsOfCreateChildTable = (char*)calloc(len+20, 1); superTbl->colsOfCreateChildTable = (char*)calloc(len+20, 1);
if (NULL == superTbl->colsOfCreateChildTable) { if (NULL == superTbl->colsOfCreateChildTable) {
taos_close(taos);
errorPrint("%s() LN%d, Failed when calloc, size:%d", errorPrint("%s() LN%d, Failed when calloc, size:%d",
__func__, __LINE__, len+1); __func__, __LINE__, len+1);
taos_close(taos); exit(EXIT_FAILURE);
exit(-1);
} }
snprintf(superTbl->colsOfCreateChildTable, len+20, "(ts timestamp%s)", cols); snprintf(superTbl->colsOfCreateChildTable, len+20, "(ts timestamp%s)", cols);
...@@ -3055,7 +3054,7 @@ static int createSuperTable( ...@@ -3055,7 +3054,7 @@ static int createSuperTable(
taos_close(taos); taos_close(taos);
errorPrint("%s() LN%d, config error tag type : %s\n", errorPrint("%s() LN%d, config error tag type : %s\n",
__func__, __LINE__, dataType); __func__, __LINE__, dataType);
exit(-1); exit(EXIT_FAILURE);
} }
} }
...@@ -3239,7 +3238,7 @@ static void* createTable(void *sarg) ...@@ -3239,7 +3238,7 @@ static void* createTable(void *sarg)
pThreadInfo->buffer = calloc(buff_len, 1); pThreadInfo->buffer = calloc(buff_len, 1);
if (pThreadInfo->buffer == NULL) { if (pThreadInfo->buffer == NULL) {
errorPrint("%s() LN%d, Memory allocated failed!\n", __func__, __LINE__); errorPrint("%s() LN%d, Memory allocated failed!\n", __func__, __LINE__);
exit(-1); exit(EXIT_FAILURE);
} }
int len = 0; int len = 0;
...@@ -3259,10 +3258,10 @@ static void* createTable(void *sarg) ...@@ -3259,10 +3258,10 @@ static void* createTable(void *sarg)
pThreadInfo->cols); pThreadInfo->cols);
} else { } else {
if (stbInfo == NULL) { if (stbInfo == NULL) {
free(pThreadInfo->buffer);
errorPrint("%s() LN%d, use metric, but super table info is NULL\n", errorPrint("%s() LN%d, use metric, but super table info is NULL\n",
__func__, __LINE__); __func__, __LINE__);
free(pThreadInfo->buffer); exit(EXIT_FAILURE);
exit(-1);
} else { } else {
if (0 == len) { if (0 == len) {
batchNum = 0; batchNum = 0;
...@@ -3270,17 +3269,23 @@ static void* createTable(void *sarg) ...@@ -3270,17 +3269,23 @@ static void* createTable(void *sarg)
len += snprintf(pThreadInfo->buffer + len, len += snprintf(pThreadInfo->buffer + len,
buff_len - len, "create table "); buff_len - len, "create table ");
} }
char* tagsValBuf = NULL; char* tagsValBuf = NULL;
if (0 == stbInfo->tagSource) { if (0 == stbInfo->tagSource) {
tagsValBuf = generateTagValuesForStb(stbInfo, i); tagsValBuf = generateTagValuesForStb(stbInfo, i);
} else { } else {
if (0 == stbInfo->tagSampleCount) {
free(pThreadInfo->buffer);
ERROR_EXIT("use sample file for tag, but has no content!\n");
}
tagsValBuf = getTagValueFromTagSample( tagsValBuf = getTagValueFromTagSample(
stbInfo, stbInfo,
i % stbInfo->tagSampleCount); i % stbInfo->tagSampleCount);
} }
if (NULL == tagsValBuf) { if (NULL == tagsValBuf) {
free(pThreadInfo->buffer); free(pThreadInfo->buffer);
return NULL; ERROR_EXIT("use metric, but tag buffer is NULL\n");
} }
len += snprintf(pThreadInfo->buffer + len, len += snprintf(pThreadInfo->buffer + len,
buff_len - len, buff_len - len,
...@@ -3333,8 +3338,7 @@ static int startMultiThreadCreateChildTable( ...@@ -3333,8 +3338,7 @@ static int startMultiThreadCreateChildTable(
threadInfo *infos = calloc(1, threads * sizeof(threadInfo)); threadInfo *infos = calloc(1, threads * sizeof(threadInfo));
if ((NULL == pids) || (NULL == infos)) { if ((NULL == pids) || (NULL == infos)) {
printf("malloc failed\n"); ERROR_EXIT("createChildTable malloc failed\n");
exit(-1);
} }
if (threads < 1) { if (threads < 1) {
...@@ -5268,7 +5272,7 @@ static int64_t generateData(char *recBuf, char **data_type, ...@@ -5268,7 +5272,7 @@ static int64_t generateData(char *recBuf, char **data_type,
if (s == NULL) { if (s == NULL) {
errorPrint("%s() LN%d, memory allocation %d bytes failed\n", errorPrint("%s() LN%d, memory allocation %d bytes failed\n",
__func__, __LINE__, lenOfBinary + 1); __func__, __LINE__, lenOfBinary + 1);
exit(-1); exit(EXIT_FAILURE);
} }
rand_string(s, lenOfBinary); rand_string(s, lenOfBinary);
pstr += sprintf(pstr, ",\"%s\"", s); pstr += sprintf(pstr, ",\"%s\"", s);
...@@ -5278,7 +5282,7 @@ static int64_t generateData(char *recBuf, char **data_type, ...@@ -5278,7 +5282,7 @@ static int64_t generateData(char *recBuf, char **data_type,
if (s == NULL) { if (s == NULL) {
errorPrint("%s() LN%d, memory allocation %d bytes failed\n", errorPrint("%s() LN%d, memory allocation %d bytes failed\n",
__func__, __LINE__, lenOfBinary + 1); __func__, __LINE__, lenOfBinary + 1);
exit(-1); exit(EXIT_FAILURE);
} }
rand_string(s, lenOfBinary); rand_string(s, lenOfBinary);
pstr += sprintf(pstr, ",\"%s\"", s); pstr += sprintf(pstr, ",\"%s\"", s);
...@@ -5286,8 +5290,7 @@ static int64_t generateData(char *recBuf, char **data_type, ...@@ -5286,8 +5290,7 @@ static int64_t generateData(char *recBuf, char **data_type,
} }
if (strlen(recBuf) > MAX_DATA_SIZE) { if (strlen(recBuf) > MAX_DATA_SIZE) {
perror("column length too long, abort"); ERROR_EXIT("column length too long, abort");
exit(-1);
} }
} }
...@@ -5375,7 +5378,7 @@ static int32_t execInsert(threadInfo *pThreadInfo, uint32_t k) ...@@ -5375,7 +5378,7 @@ static int32_t execInsert(threadInfo *pThreadInfo, uint32_t k)
__func__, __LINE__, taos_stmt_errstr(pThreadInfo->stmt)); __func__, __LINE__, taos_stmt_errstr(pThreadInfo->stmt));
fprintf(stderr, "\n\033[31m === Please reduce batch number if WAL size exceeds limit. ===\033[0m\n\n"); fprintf(stderr, "\n\033[31m === Please reduce batch number if WAL size exceeds limit. ===\033[0m\n\n");
exit(-1); exit(EXIT_FAILURE);
} }
affectedRows = k; affectedRows = k;
break; break;
...@@ -7391,7 +7394,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, ...@@ -7391,7 +7394,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
#endif #endif
} else { } else {
errorPrint("Not support precision: %s\n", precision); errorPrint("Not support precision: %s\n", precision);
exit(-1); exit(EXIT_FAILURE);
} }
} }
...@@ -7422,7 +7425,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, ...@@ -7422,7 +7425,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
if (0 != prepareSampleDataForSTable(stbInfo)) { if (0 != prepareSampleDataForSTable(stbInfo)) {
errorPrint("%s() LN%d, prepare sample data for stable failed!\n", errorPrint("%s() LN%d, prepare sample data for stable failed!\n",
__func__, __LINE__); __func__, __LINE__);
exit(-1); exit(EXIT_FAILURE);
} }
} }
...@@ -7432,7 +7435,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, ...@@ -7432,7 +7435,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
if (NULL == taos0) { if (NULL == taos0) {
errorPrint("%s() LN%d, connect to server fail , reason: %s\n", errorPrint("%s() LN%d, connect to server fail , reason: %s\n",
__func__, __LINE__, taos_errstr(NULL)); __func__, __LINE__, taos_errstr(NULL));
exit(-1); exit(EXIT_FAILURE);
} }
int64_t ntables = 0; int64_t ntables = 0;
...@@ -7484,9 +7487,9 @@ static void startMultiThreadInsertData(int threads, char* db_name, ...@@ -7484,9 +7487,9 @@ static void startMultiThreadInsertData(int threads, char* db_name,
stbInfo->childTblName = (char*)calloc(1, stbInfo->childTblName = (char*)calloc(1,
limit * TSDB_TABLE_NAME_LEN); limit * TSDB_TABLE_NAME_LEN);
if (stbInfo->childTblName == NULL) { if (stbInfo->childTblName == NULL) {
errorPrint("%s() LN%d, alloc memory failed!\n", __func__, __LINE__);
taos_close(taos0); taos_close(taos0);
exit(-1); errorPrint("%s() LN%d, alloc memory failed!\n", __func__, __LINE__);
exit(EXIT_FAILURE);
} }
int64_t childTblCount; int64_t childTblCount;
...@@ -7518,7 +7521,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, ...@@ -7518,7 +7521,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
&& (stbInfo->iface == REST_IFACE)) { && (stbInfo->iface == REST_IFACE)) {
if (convertHostToServAddr( if (convertHostToServAddr(
g_Dbs.host, g_Dbs.port, &(g_Dbs.serv_addr)) != 0) { g_Dbs.host, g_Dbs.port, &(g_Dbs.serv_addr)) != 0) {
exit(-1); ERROR_EXIT("convert host to server address");
} }
} }
...@@ -7592,12 +7595,12 @@ static void startMultiThreadInsertData(int threads, char* db_name, ...@@ -7592,12 +7595,12 @@ static void startMultiThreadInsertData(int threads, char* db_name,
g_Dbs.host, g_Dbs.user, g_Dbs.host, g_Dbs.user,
g_Dbs.password, db_name, g_Dbs.port); g_Dbs.password, db_name, g_Dbs.port);
if (NULL == pThreadInfo->taos) { if (NULL == pThreadInfo->taos) {
free(infos);
errorPrint( errorPrint(
"%s() LN%d, connect to server fail from insert sub thread, reason: %s\n", "%s() LN%d, connect to server fail from insert sub thread, reason: %s\n",
__func__, __LINE__, __func__, __LINE__,
taos_errstr(NULL)); taos_errstr(NULL));
free(infos); exit(EXIT_FAILURE);
exit(-1);
} }
#if STMT_IFACE_ENABLED == 1 #if STMT_IFACE_ENABLED == 1
...@@ -7608,23 +7611,23 @@ static void startMultiThreadInsertData(int threads, char* db_name, ...@@ -7608,23 +7611,23 @@ static void startMultiThreadInsertData(int threads, char* db_name,
pThreadInfo->stmt = taos_stmt_init(pThreadInfo->taos); pThreadInfo->stmt = taos_stmt_init(pThreadInfo->taos);
if (NULL == pThreadInfo->stmt) { if (NULL == pThreadInfo->stmt) {
free(pids);
free(infos);
errorPrint( errorPrint(
"%s() LN%d, failed init stmt, reason: %s\n", "%s() LN%d, failed init stmt, reason: %s\n",
__func__, __LINE__, __func__, __LINE__,
taos_errstr(NULL)); taos_errstr(NULL));
free(pids); exit(EXIT_FAILURE);
free(infos);
exit(-1);
} }
int ret = taos_stmt_prepare(pThreadInfo->stmt, stmtBuffer, 0); int ret = taos_stmt_prepare(pThreadInfo->stmt, stmtBuffer, 0);
if (ret != 0){ if (ret != 0){
errorPrint("failed to execute taos_stmt_prepare. return 0x%x. reason: %s\n",
ret, taos_stmt_errstr(pThreadInfo->stmt));
free(pids); free(pids);
free(infos); free(infos);
free(stmtBuffer); free(stmtBuffer);
exit(-1); errorPrint("failed to execute taos_stmt_prepare. return 0x%x. reason: %s\n",
ret, taos_stmt_errstr(pThreadInfo->stmt));
exit(EXIT_FAILURE);
} }
pThreadInfo->bind_ts = malloc(sizeof(int64_t)); pThreadInfo->bind_ts = malloc(sizeof(int64_t));
} }
...@@ -8199,7 +8202,7 @@ static int queryTestProcess() { ...@@ -8199,7 +8202,7 @@ static int queryTestProcess() {
if (taos == NULL) { if (taos == NULL) {
errorPrint( "Failed to connect to TDengine, reason:%s\n", errorPrint( "Failed to connect to TDengine, reason:%s\n",
taos_errstr(NULL)); taos_errstr(NULL));
exit(-1); exit(EXIT_FAILURE);
} }
if (0 != g_queryInfo.superQueryInfo.sqlCount) { if (0 != g_queryInfo.superQueryInfo.sqlCount) {
...@@ -8219,7 +8222,7 @@ static int queryTestProcess() { ...@@ -8219,7 +8222,7 @@ static int queryTestProcess() {
if (0 == strncasecmp(g_queryInfo.queryMode, "rest", strlen("rest"))) { if (0 == strncasecmp(g_queryInfo.queryMode, "rest", strlen("rest"))) {
if (convertHostToServAddr( if (convertHostToServAddr(
g_queryInfo.host, g_queryInfo.port, &g_queryInfo.serv_addr) != 0) g_queryInfo.host, g_queryInfo.port, &g_queryInfo.serv_addr) != 0)
exit(-1); ERROR_EXIT("convert host to server address");
} }
pthread_t *pids = NULL; pthread_t *pids = NULL;
...@@ -8423,7 +8426,7 @@ static void *superSubscribe(void *sarg) { ...@@ -8423,7 +8426,7 @@ static void *superSubscribe(void *sarg) {
if (pThreadInfo->ntables > MAX_QUERY_SQL_COUNT) { if (pThreadInfo->ntables > MAX_QUERY_SQL_COUNT) {
errorPrint("The table number(%"PRId64") of the thread is more than max query sql count: %d\n", errorPrint("The table number(%"PRId64") of the thread is more than max query sql count: %d\n",
pThreadInfo->ntables, MAX_QUERY_SQL_COUNT); pThreadInfo->ntables, MAX_QUERY_SQL_COUNT);
exit(-1); exit(EXIT_FAILURE);
} }
if (pThreadInfo->taos == NULL) { if (pThreadInfo->taos == NULL) {
...@@ -8684,7 +8687,7 @@ static int subscribeTestProcess() { ...@@ -8684,7 +8687,7 @@ static int subscribeTestProcess() {
if (taos == NULL) { if (taos == NULL) {
errorPrint( "Failed to connect to TDengine, reason:%s\n", errorPrint( "Failed to connect to TDengine, reason:%s\n",
taos_errstr(NULL)); taos_errstr(NULL));
exit(-1); exit(EXIT_FAILURE);
} }
if (0 != g_queryInfo.superQueryInfo.sqlCount) { if (0 != g_queryInfo.superQueryInfo.sqlCount) {
...@@ -8713,7 +8716,7 @@ static int subscribeTestProcess() { ...@@ -8713,7 +8716,7 @@ static int subscribeTestProcess() {
errorPrint("%s() LN%d, sepcified query sqlCount %d.\n", errorPrint("%s() LN%d, sepcified query sqlCount %d.\n",
__func__, __LINE__, __func__, __LINE__,
g_queryInfo.specifiedQueryInfo.sqlCount); g_queryInfo.specifiedQueryInfo.sqlCount);
exit(-1); exit(EXIT_FAILURE);
} }
pids = calloc( pids = calloc(
...@@ -8728,7 +8731,7 @@ static int subscribeTestProcess() { ...@@ -8728,7 +8731,7 @@ static int subscribeTestProcess() {
sizeof(threadInfo)); sizeof(threadInfo));
if ((NULL == pids) || (NULL == infos)) { if ((NULL == pids) || (NULL == infos)) {
errorPrint("%s() LN%d, malloc failed for create threads\n", __func__, __LINE__); errorPrint("%s() LN%d, malloc failed for create threads\n", __func__, __LINE__);
exit(-1); exit(EXIT_FAILURE);
} }
for (int i = 0; i < g_queryInfo.specifiedQueryInfo.sqlCount; i++) { for (int i = 0; i < g_queryInfo.specifiedQueryInfo.sqlCount; i++) {
...@@ -8765,7 +8768,7 @@ static int subscribeTestProcess() { ...@@ -8765,7 +8768,7 @@ static int subscribeTestProcess() {
errorPrint("%s() LN%d, malloc failed for create threads\n", errorPrint("%s() LN%d, malloc failed for create threads\n",
__func__, __LINE__); __func__, __LINE__);
// taos_close(taos); // taos_close(taos);
exit(-1); exit(EXIT_FAILURE);
} }
int64_t ntables = g_queryInfo.superQueryInfo.childTblCount; int64_t ntables = g_queryInfo.superQueryInfo.childTblCount;
...@@ -8970,8 +8973,7 @@ static int regexMatch(const char *s, const char *reg, int cflags) { ...@@ -8970,8 +8973,7 @@ static int regexMatch(const char *s, const char *reg, int cflags) {
/* Compile regular expression */ /* Compile regular expression */
if (regcomp(&regex, reg, cflags) != 0) { if (regcomp(&regex, reg, cflags) != 0) {
printf("Fail to compile regex\n"); ERROR_EXIT("Fail to compile regex\n");
exit(-1);
} }
/* Execute regular expression */ /* Execute regular expression */
...@@ -8984,9 +8986,9 @@ static int regexMatch(const char *s, const char *reg, int cflags) { ...@@ -8984,9 +8986,9 @@ static int regexMatch(const char *s, const char *reg, int cflags) {
return 0; return 0;
} else { } else {
regerror(reti, &regex, msgbuf, sizeof(msgbuf)); regerror(reti, &regex, msgbuf, sizeof(msgbuf));
printf("Regex match failed: %s\n", msgbuf);
regfree(&regex); regfree(&regex);
exit(-1); printf("Regex match failed: %s\n", msgbuf);
exit(EXIT_FAILURE);
} }
return 0; return 0;
...@@ -9104,10 +9106,10 @@ static void queryResult() { ...@@ -9104,10 +9106,10 @@ static void queryResult() {
g_Dbs.db[0].dbName, g_Dbs.db[0].dbName,
g_Dbs.port); g_Dbs.port);
if (pThreadInfo->taos == NULL) { if (pThreadInfo->taos == NULL) {
free(pThreadInfo);
errorPrint( "Failed to connect to TDengine, reason:%s\n", errorPrint( "Failed to connect to TDengine, reason:%s\n",
taos_errstr(NULL)); taos_errstr(NULL));
free(pThreadInfo); exit(EXIT_FAILURE);
exit(-1);
} }
tstrncpy(pThreadInfo->filePath, g_Dbs.resultFile, MAX_FILE_NAME_LEN); tstrncpy(pThreadInfo->filePath, g_Dbs.resultFile, MAX_FILE_NAME_LEN);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册