Merge pull request #9707 from taosdata/feature/3.0_wxy
TD-12678 bug fix
This commit is contained in:
commit
519fce0f61
|
@ -305,6 +305,8 @@ TAOS_RES *taos_query_l(TAOS *taos, const char *sql, int sqlLen) {
|
||||||
} else {
|
} else {
|
||||||
CHECK_CODE_GOTO(getPlan(pRequest, pQuery, &pDag), _return);
|
CHECK_CODE_GOTO(getPlan(pRequest, pQuery, &pDag), _return);
|
||||||
CHECK_CODE_GOTO(scheduleQuery(pRequest, pDag, &pJob), _return);
|
CHECK_CODE_GOTO(scheduleQuery(pRequest, pDag, &pJob), _return);
|
||||||
|
pRequest->code = terrno;
|
||||||
|
return pRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
|
@ -112,6 +112,9 @@ public:
|
||||||
int32_t catalogGetTableHashVgroup(const SName* pTableName, SVgroupInfo* vgInfo) const {
|
int32_t catalogGetTableHashVgroup(const SName* pTableName, SVgroupInfo* vgInfo) const {
|
||||||
// todo
|
// todo
|
||||||
vgInfo->vgId = 1;
|
vgInfo->vgId = 1;
|
||||||
|
vgInfo->numOfEps = 1;
|
||||||
|
vgInfo->epAddr[0].port = 6030;
|
||||||
|
strcpy(vgInfo->epAddr[0].fqdn, "node1");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -234,7 +234,7 @@ static SSubplan* initSubplan(SPlanContext* pCxt, int32_t type) {
|
||||||
|
|
||||||
static void vgroupInfoToEpSet(const SVgroupInfo* vg, SQueryNodeAddr* execNode) {
|
static void vgroupInfoToEpSet(const SVgroupInfo* vg, SQueryNodeAddr* execNode) {
|
||||||
execNode->nodeId = vg->vgId;
|
execNode->nodeId = vg->vgId;
|
||||||
execNode->inUse = 0; // todo
|
execNode->inUse = vg->inUse;
|
||||||
execNode->numOfEps = vg->numOfEps;
|
execNode->numOfEps = vg->numOfEps;
|
||||||
for (int8_t i = 0; i < vg->numOfEps; ++i) {
|
for (int8_t i = 0; i < vg->numOfEps; ++i) {
|
||||||
execNode->epAddr[i] = vg->epAddr[i];
|
execNode->epAddr[i] = vg->epAddr[i];
|
||||||
|
|
|
@ -62,7 +62,7 @@ static bool fromObjectWithAlloc(const cJSON* json, const char* name, FFromJson f
|
||||||
return func(jObj, *obj);
|
return func(jObj, *obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool addArray(cJSON* json, const char* name, FToJson func, const SArray* array) {
|
static bool addTarray(cJSON* json, const char* name, FToJson func, const SArray* array, bool isPoint) {
|
||||||
size_t size = (NULL == array) ? 0 : taosArrayGetSize(array);
|
size_t size = (NULL == array) ? 0 : taosArrayGetSize(array);
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
cJSON* jArray = cJSON_AddArrayToObject(json, name);
|
cJSON* jArray = cJSON_AddArrayToObject(json, name);
|
||||||
|
@ -70,7 +70,7 @@ static bool addArray(cJSON* json, const char* name, FToJson func, const SArray*
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < size; ++i) {
|
for (size_t i = 0; i < size; ++i) {
|
||||||
if (!addItem(jArray, func, taosArrayGetP(array, i))) {
|
if (!addItem(jArray, func, isPoint ? taosArrayGetP(array, i) : taosArrayGet(array, i))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,11 +78,19 @@ static bool addArray(cJSON* json, const char* name, FToJson func, const SArray*
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool fromArray(const cJSON* json, const char* name, FFromJson func, SArray** array, int32_t itemSize) {
|
static bool addInlineArray(cJSON* json, const char* name, FToJson func, const SArray* array) {
|
||||||
|
return addTarray(json, name, func, array, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool addArray(cJSON* json, const char* name, FToJson func, const SArray* array) {
|
||||||
|
return addTarray(json, name, func, array, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool fromTarray(const cJSON* json, const char* name, FFromJson func, SArray** array, int32_t itemSize, bool isPoint) {
|
||||||
const cJSON* jArray = cJSON_GetObjectItem(json, name);
|
const cJSON* jArray = cJSON_GetObjectItem(json, name);
|
||||||
int32_t size = (NULL == jArray ? 0 : cJSON_GetArraySize(jArray));
|
int32_t size = (NULL == jArray ? 0 : cJSON_GetArraySize(jArray));
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
*array = taosArrayInit(size, POINTER_BYTES);
|
*array = taosArrayInit(size, isPoint ? POINTER_BYTES : itemSize);
|
||||||
if (NULL == *array) {
|
if (NULL == *array) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -92,11 +100,19 @@ static bool fromArray(const cJSON* json, const char* name, FFromJson func, SArra
|
||||||
if (NULL == item || !func(cJSON_GetArrayItem(jArray, i), item)) {
|
if (NULL == item || !func(cJSON_GetArrayItem(jArray, i), item)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
taosArrayPush(*array, &item);
|
taosArrayPush(*array, isPoint ? &item : item);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool fromInlineArray(const cJSON* json, const char* name, FFromJson func, SArray** array, int32_t itemSize) {
|
||||||
|
return fromTarray(json, name, func, array, itemSize, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool fromArray(const cJSON* json, const char* name, FFromJson func, SArray** array, int32_t itemSize) {
|
||||||
|
return fromTarray(json, name, func, array, itemSize, true);
|
||||||
|
}
|
||||||
|
|
||||||
static bool addRawArray(cJSON* json, const char* name, FToJson func, const void* array, int32_t itemSize, int32_t size) {
|
static bool addRawArray(cJSON* json, const char* name, FToJson func, const void* array, int32_t itemSize, int32_t size) {
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
cJSON* jArray = cJSON_AddArrayToObject(json, name);
|
cJSON* jArray = cJSON_AddArrayToObject(json, name);
|
||||||
|
@ -556,6 +572,32 @@ static bool epAddrFromJson(const cJSON* json, void* obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* jkNodeAddrId = "NodeId";
|
||||||
|
static const char* jkNodeAddrInUse = "InUse";
|
||||||
|
static const char* jkNodeAddrEpAddrs = "EpAddrs";
|
||||||
|
|
||||||
|
static bool nodeAddrToJson(const void* obj, cJSON* json) {
|
||||||
|
const SQueryNodeAddr* ep = (const SQueryNodeAddr*)obj;
|
||||||
|
bool res = cJSON_AddNumberToObject(json, jkNodeAddrId, ep->nodeId);
|
||||||
|
if (res) {
|
||||||
|
res = cJSON_AddNumberToObject(json, jkNodeAddrInUse, ep->inUse);
|
||||||
|
}
|
||||||
|
if (res) {
|
||||||
|
res = addRawArray(json, jkNodeAddrEpAddrs, epAddrToJson, ep->epAddr, ep->numOfEps, sizeof(SEpAddrMsg));
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool nodeAddrFromJson(const cJSON* json, void* obj) {
|
||||||
|
SQueryNodeAddr* ep = (SQueryNodeAddr*)obj;
|
||||||
|
ep->nodeId = getNumber(json, jkNodeAddrId);
|
||||||
|
ep->inUse = getNumber(json, jkNodeAddrInUse);
|
||||||
|
int32_t numOfEps = 0;
|
||||||
|
bool res = fromRawArray(json, jkNodeAddrEpAddrs, nodeAddrFromJson, &ep->epAddr, sizeof(SEpAddrMsg), &numOfEps);
|
||||||
|
ep->numOfEps = numOfEps;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
static const char* jkExchangeNodeSrcTemplateId = "SrcTemplateId";
|
static const char* jkExchangeNodeSrcTemplateId = "SrcTemplateId";
|
||||||
static const char* jkExchangeNodeSrcEndPoints = "SrcEndPoints";
|
static const char* jkExchangeNodeSrcEndPoints = "SrcEndPoints";
|
||||||
|
|
||||||
|
@ -563,7 +605,7 @@ static bool exchangeNodeToJson(const void* obj, cJSON* json) {
|
||||||
const SExchangePhyNode* exchange = (const SExchangePhyNode*)obj;
|
const SExchangePhyNode* exchange = (const SExchangePhyNode*)obj;
|
||||||
bool res = cJSON_AddNumberToObject(json, jkExchangeNodeSrcTemplateId, exchange->srcTemplateId);
|
bool res = cJSON_AddNumberToObject(json, jkExchangeNodeSrcTemplateId, exchange->srcTemplateId);
|
||||||
if (res) {
|
if (res) {
|
||||||
res = addArray(json, jkExchangeNodeSrcEndPoints, epAddrToJson, exchange->pSrcEndPoints);
|
res = addInlineArray(json, jkExchangeNodeSrcEndPoints, nodeAddrToJson, exchange->pSrcEndPoints);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -571,7 +613,7 @@ static bool exchangeNodeToJson(const void* obj, cJSON* json) {
|
||||||
static bool exchangeNodeFromJson(const cJSON* json, void* obj) {
|
static bool exchangeNodeFromJson(const cJSON* json, void* obj) {
|
||||||
SExchangePhyNode* exchange = (SExchangePhyNode*)obj;
|
SExchangePhyNode* exchange = (SExchangePhyNode*)obj;
|
||||||
exchange->srcTemplateId = getNumber(json, jkExchangeNodeSrcTemplateId);
|
exchange->srcTemplateId = getNumber(json, jkExchangeNodeSrcTemplateId);
|
||||||
return fromArray(json, jkExchangeNodeSrcEndPoints, epAddrFromJson, &exchange->pSrcEndPoints, sizeof(SEpAddrMsg));
|
return fromInlineArray(json, jkExchangeNodeSrcEndPoints, nodeAddrFromJson, &exchange->pSrcEndPoints, sizeof(SQueryNodeAddr));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool specificPhyNodeToJson(const void* obj, cJSON* json) {
|
static bool specificPhyNodeToJson(const void* obj, cJSON* json) {
|
||||||
|
@ -803,7 +845,6 @@ static cJSON* subplanToJson(const SSubplan* subplan) {
|
||||||
if (res) {
|
if (res) {
|
||||||
res = addObject(jSubplan, jkSubplanDataSink, dataSinkToJson, subplan->pDataSink);
|
res = addObject(jSubplan, jkSubplanDataSink, dataSinkToJson, subplan->pDataSink);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!res) {
|
if (!res) {
|
||||||
cJSON_Delete(jSubplan);
|
cJSON_Delete(jSubplan);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue