提交 ddfa301e 编写于 作者: H hjxilinx

refactor some codes

上级 cf1ae56e
...@@ -30,10 +30,10 @@ extern "C" { ...@@ -30,10 +30,10 @@ extern "C" {
#include "tsdb.h" #include "tsdb.h"
#include "tscSecondaryMerge.h" #include "tscSecondaryMerge.h"
#define UTIL_METER_IS_METRIC(cmd) (((cmd)->pMeterMeta != NULL) && ((cmd)->pMeterMeta->meterType == TSDB_METER_METRIC)) #define UTIL_METER_IS_METRIC(metaInfo) (((metaInfo)->pMeterMeta != NULL) && ((metaInfo)->pMeterMeta->meterType == TSDB_METER_METRIC))
#define UTIL_METER_IS_NOMRAL_METER(cmd) (!(UTIL_METER_IS_METRIC(cmd))) #define UTIL_METER_IS_NOMRAL_METER(metaInfo) (!(UTIL_METER_IS_METRIC(metaInfo)))
#define UTIL_METER_IS_CREATE_FROM_METRIC(cmd) \ #define UTIL_METER_IS_CREATE_FROM_METRIC(metaInfo) \
(((cmd)->pMeterMeta != NULL) && ((cmd)->pMeterMeta->meterType == TSDB_METER_MTABLE)) (((metaInfo)->pMeterMeta != NULL) && ((metaInfo)->pMeterMeta->meterType == TSDB_METER_MTABLE))
#define TSDB_COL_IS_TAG(f) (((f)&TSDB_COL_TAG) != 0) #define TSDB_COL_IS_TAG(f) (((f)&TSDB_COL_TAG) != 0)
......
...@@ -3779,9 +3779,6 @@ static void getStatics_i64(int64_t *primaryKey, int64_t *data, int32_t numOfRow, ...@@ -3779,9 +3779,6 @@ static void getStatics_i64(int64_t *primaryKey, int64_t *data, int32_t numOfRow,
assert(numOfRow <= INT16_MAX); assert(numOfRow <= INT16_MAX);
int64_t lastKey = 0;
int64_t lastVal = TSDB_DATA_BIGINT_NULL;
for (int32_t i = 0; i < numOfRow; ++i) { for (int32_t i = 0; i < numOfRow; ++i) {
if (isNull(&data[i], TSDB_DATA_TYPE_BIGINT)) { if (isNull(&data[i], TSDB_DATA_TYPE_BIGINT)) {
(*numOfNull) += 1; (*numOfNull) += 1;
...@@ -3873,9 +3870,6 @@ static void getStatics_d(int64_t *primaryKey, double *data, int32_t numOfRow, do ...@@ -3873,9 +3870,6 @@ static void getStatics_d(int64_t *primaryKey, double *data, int32_t numOfRow, do
assert(numOfRow <= INT16_MAX); assert(numOfRow <= INT16_MAX);
int64_t lastKey = 0;
double lastVal = TSDB_DATA_DOUBLE_NULL;
for (int32_t i = 0; i < numOfRow; ++i) { for (int32_t i = 0; i < numOfRow; ++i) {
if (isNull(&data[i], TSDB_DATA_TYPE_DOUBLE)) { if (isNull(&data[i], TSDB_DATA_TYPE_DOUBLE)) {
(*numOfNull) += 1; (*numOfNull) += 1;
......
...@@ -5668,8 +5668,7 @@ int32_t doFunctionsCompatibleCheck(SSqlObj* pSql) { ...@@ -5668,8 +5668,7 @@ int32_t doFunctionsCompatibleCheck(SSqlObj* pSql) {
} }
if (IS_MULTIOUTPUT(aAggs[functId].nStatus) && functId != TSDB_FUNC_TOP && functId != TSDB_FUNC_BOTTOM && if (IS_MULTIOUTPUT(aAggs[functId].nStatus) && functId != TSDB_FUNC_TOP && functId != TSDB_FUNC_BOTTOM &&
functId != TSDB_FUNC_TAGPRJ && functId != TSDB_FUNC_TAGPRJ && functId != TSDB_FUNC_PRJ) {
(functId == TSDB_FUNC_PRJ && pExpr->colInfo.colId != PRIMARYKEY_TIMESTAMP_COL_INDEX)) {
setErrMsg(pCmd, msg1); setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL; return TSDB_CODE_INVALID_SQL;
} }
...@@ -5697,6 +5696,8 @@ int32_t doFunctionsCompatibleCheck(SSqlObj* pSql) { ...@@ -5697,6 +5696,8 @@ int32_t doFunctionsCompatibleCheck(SSqlObj* pSql) {
setErrMsg(pCmd, msg3); setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL; return TSDB_CODE_INVALID_SQL;
} }
return TSDB_CODE_SUCCESS;
} else { } else {
return checkUpdateTagPrjFunctions(pCmd); return checkUpdateTagPrjFunctions(pCmd);
} }
......
...@@ -723,9 +723,16 @@ int tscProcessSql(SSqlObj *pSql) { ...@@ -723,9 +723,16 @@ int tscProcessSql(SSqlObj *pSql) {
#else #else
pSql->maxRetry = 2; pSql->maxRetry = 2;
#endif #endif
// the pMeterMetaInfo cannot be NULL
if (pMeterMetaInfo == NULL) {
pSql->res.code = TSDB_CODE_OTHERS;
return pSql->res.code;
}
if (UTIL_METER_IS_NOMRAL_METER(pMeterMetaInfo)) { if (UTIL_METER_IS_NOMRAL_METER(pMeterMetaInfo)) {
pSql->index = pMeterMetaInfo->pMeterMeta->index; pSql->index = pMeterMetaInfo->pMeterMeta->index;
} else { // it must be the parent SSqlObj for metric query } else { // it must be the parent SSqlObj for super table query
if ((pSql->cmd.type & TSDB_QUERY_TYPE_SUBQUERY) != 0) { if ((pSql->cmd.type & TSDB_QUERY_TYPE_SUBQUERY) != 0) {
int32_t idx = pSql->cmd.vnodeIdx; int32_t idx = pSql->cmd.vnodeIdx;
SVnodeSidList *pSidList = tscGetVnodeSidList(pMeterMetaInfo->pMetricMeta, idx); SVnodeSidList *pSidList = tscGetVnodeSidList(pMeterMetaInfo->pMetricMeta, idx);
...@@ -3770,7 +3777,7 @@ void tscInitMsgs() { ...@@ -3770,7 +3777,7 @@ void tscInitMsgs() {
tscProcessMsgRsp[TSDB_SQL_MULTI_META] = tscProcessMultiMeterMetaRsp; tscProcessMsgRsp[TSDB_SQL_MULTI_META] = tscProcessMultiMeterMetaRsp;
tscProcessMsgRsp[TSDB_SQL_SHOW] = tscProcessShowRsp; tscProcessMsgRsp[TSDB_SQL_SHOW] = tscProcessShowRsp;
tscProcessMsgRsp[TSDB_SQL_RETRIEVE] = tscProcessRetrieveRspFromMgmt; tscProcessMsgRsp[TSDB_SQL_RETRIEVE] = tscProcessRetrieveRspFromVnode; // rsp handled by same function.
tscProcessMsgRsp[TSDB_SQL_DESCRIBE_TABLE] = tscProcessDescribeTableRsp; tscProcessMsgRsp[TSDB_SQL_DESCRIBE_TABLE] = tscProcessDescribeTableRsp;
tscProcessMsgRsp[TSDB_SQL_RETRIEVE_TAGS] = tscProcessTagRetrieveRsp; tscProcessMsgRsp[TSDB_SQL_RETRIEVE_TAGS] = tscProcessTagRetrieveRsp;
tscProcessMsgRsp[TSDB_SQL_RETRIEVE_EMPTY_RESULT] = tscProcessEmptyResultRsp; tscProcessMsgRsp[TSDB_SQL_RETRIEVE_EMPTY_RESULT] = tscProcessEmptyResultRsp;
......
...@@ -25,6 +25,7 @@ extern "C" { ...@@ -25,6 +25,7 @@ extern "C" {
#include <arpa/inet.h> #include <arpa/inet.h>
#include <assert.h> #include <assert.h>
#include <ctype.h>
#include <dirent.h> #include <dirent.h>
#include <endian.h> #include <endian.h>
#include <float.h> #include <float.h>
...@@ -61,6 +62,7 @@ extern "C" { ...@@ -61,6 +62,7 @@ extern "C" {
#include <unistd.h> #include <unistd.h>
#include <wchar.h> #include <wchar.h>
#include <wordexp.h> #include <wordexp.h>
#include <wctype.h>
#define taosCloseSocket(x) \ #define taosCloseSocket(x) \
{ \ { \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册