[td-225]fix bugs found by regression test.
This commit is contained in:
parent
e655a68f69
commit
5ade893fd9
|
@ -321,6 +321,8 @@ CChildTableMeta* tscCreateChildMeta(STableMeta* pTableMeta);
|
||||||
uint32_t tscGetTableMetaMaxSize();
|
uint32_t tscGetTableMetaMaxSize();
|
||||||
int32_t tscCreateTableMetaFromCChildMeta(STableMeta* pChild, const char* name, void* buf);
|
int32_t tscCreateTableMetaFromCChildMeta(STableMeta* pChild, const char* name, void* buf);
|
||||||
STableMeta* tscTableMetaDup(STableMeta* pTableMeta);
|
STableMeta* tscTableMetaDup(STableMeta* pTableMeta);
|
||||||
|
SVgroupsInfo* tscVgroupsInfoDup(SVgroupsInfo* pVgroupsInfo);
|
||||||
|
|
||||||
int32_t tscCreateQueryFromQueryInfo(SQueryInfo* pQueryInfo, SQueryAttr* pQueryAttr, void* addr);
|
int32_t tscCreateQueryFromQueryInfo(SQueryInfo* pQueryInfo, SQueryAttr* pQueryAttr, void* addr);
|
||||||
|
|
||||||
void tsCreateSQLFunctionCtx(SQueryInfo* pQueryInfo, SQLFunctionCtx* pCtx, SSchema* pSchema);
|
void tsCreateSQLFunctionCtx(SQueryInfo* pQueryInfo, SQLFunctionCtx* pCtx, SSchema* pSchema);
|
||||||
|
|
|
@ -83,10 +83,10 @@ typedef struct STableMeta {
|
||||||
} STableMeta;
|
} STableMeta;
|
||||||
|
|
||||||
typedef struct STableMetaInfo {
|
typedef struct STableMetaInfo {
|
||||||
STableMeta *pTableMeta; // table meta, cached in client side and acquired by name
|
STableMeta *pTableMeta; // table meta, cached in client side and acquired by name
|
||||||
uint32_t tableMetaSize;
|
uint32_t tableMetaSize;
|
||||||
SVgroupsInfo *vgroupList;
|
SVgroupsInfo *vgroupList;
|
||||||
SArray *pVgroupTables; // SArray<SVgroupTableInfo>
|
SArray *pVgroupTables; // SArray<SVgroupTableInfo>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 1. keep the vgroup index during the multi-vnode super table projection query
|
* 1. keep the vgroup index during the multi-vnode super table projection query
|
||||||
|
|
|
@ -7241,7 +7241,6 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
STableMeta* pMeta = tscTableMetaDup(pTableMeta);
|
STableMeta* pMeta = tscTableMetaDup(pTableMeta);
|
||||||
|
|
||||||
STableMetaVgroupInfo p = { .pTableMeta = pMeta };
|
STableMetaVgroupInfo p = { .pTableMeta = pMeta };
|
||||||
|
|
||||||
const char* px = tNameGetTableName(pname);
|
const char* px = tNameGetTableName(pname);
|
||||||
|
@ -7279,10 +7278,15 @@ static int32_t doLoadAllTableMeta(SSqlObj* pSql, SQueryInfo* pQueryInfo, SSqlNod
|
||||||
const char* msg1 = "invalid table name";
|
const char* msg1 = "invalid table name";
|
||||||
const char* msg2 = "invalid table alias name";
|
const char* msg2 = "invalid table alias name";
|
||||||
const char* msg3 = "alias name too long";
|
const char* msg3 = "alias name too long";
|
||||||
|
const char* msg4 = "self join not allowed";
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
SSqlCmd* pCmd = &pSql->cmd;
|
SSqlCmd* pCmd = &pSql->cmd;
|
||||||
|
|
||||||
|
if (numOfTables > taosHashGetSize(pCmd->pTableMetaMap)) {
|
||||||
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg4);
|
||||||
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfTables; ++i) {
|
for (int32_t i = 0; i < numOfTables; ++i) {
|
||||||
if (pQueryInfo->numOfTables <= i) { // more than one table
|
if (pQueryInfo->numOfTables <= i) { // more than one table
|
||||||
tscAddEmptyMetaInfo(pQueryInfo);
|
tscAddEmptyMetaInfo(pQueryInfo);
|
||||||
|
@ -7325,11 +7329,13 @@ static int32_t doLoadAllTableMeta(SSqlObj* pSql, SQueryInfo* pQueryInfo, SSqlNod
|
||||||
const char* name = tNameGetTableName(&pTableMetaInfo->name);
|
const char* name = tNameGetTableName(&pTableMetaInfo->name);
|
||||||
STableMetaVgroupInfo* p = taosHashGet(pCmd->pTableMetaMap, name, strlen(name));
|
STableMetaVgroupInfo* p = taosHashGet(pCmd->pTableMetaMap, name, strlen(name));
|
||||||
|
|
||||||
pTableMetaInfo->pTableMeta = p->pTableMeta;
|
pTableMetaInfo->pTableMeta = tscTableMetaDup(p->pTableMeta);
|
||||||
pTableMetaInfo->vgroupList = p->pVgroupInfo;
|
|
||||||
|
|
||||||
assert(pTableMetaInfo->pTableMeta != NULL);
|
assert(pTableMetaInfo->pTableMeta != NULL);
|
||||||
|
|
||||||
|
if (p->pVgroupInfo != NULL) {
|
||||||
|
pTableMetaInfo->vgroupList = tscVgroupsInfoDup(p->pVgroupInfo);
|
||||||
|
}
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -7556,7 +7562,6 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
|
||||||
*/
|
*/
|
||||||
if (isSTable) {
|
if (isSTable) {
|
||||||
tscTansformFuncForSTableQuery(pQueryInfo);
|
tscTansformFuncForSTableQuery(pQueryInfo);
|
||||||
|
|
||||||
if (hasUnsupportFunctionsForSTableQuery(pCmd, pQueryInfo)) {
|
if (hasUnsupportFunctionsForSTableQuery(pCmd, pQueryInfo)) {
|
||||||
return TSDB_CODE_TSC_INVALID_SQL;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1722,23 +1722,6 @@ int tscBuildTableMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
int tscBuildMultiTableMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
int tscBuildMultiTableMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
|
|
||||||
// copy payload content to temp buf
|
|
||||||
// char *tmpData = 0;
|
|
||||||
// if (pCmd->payloadLen > 0) {
|
|
||||||
// if ((tmpData = calloc(1, pCmd->payloadLen + 1)) == NULL) return -1;
|
|
||||||
// memcpy(tmpData, pCmd->payload, pCmd->payloadLen);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// SMultiTableInfoMsg *pInfoMsg = (SMultiTableInfoMsg *)(pCmd->payload);
|
|
||||||
// pInfoMsg->numOfTables = htonl((int32_t)pCmd->count);
|
|
||||||
//
|
|
||||||
// if (pCmd->payloadLen > 0) {
|
|
||||||
// memcpy(pInfoMsg->tableIds, tmpData, pCmd->payloadLen);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// tfree(tmpData);
|
|
||||||
|
|
||||||
// pCmd->payloadLen += sizeof(SMgmtHead) + sizeof(SMultiTableInfoMsg);
|
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_CM_TABLES_META;
|
pCmd->msgType = TSDB_MSG_TYPE_CM_TABLES_META;
|
||||||
assert(pCmd->payloadLen + minMsgSize() <= pCmd->allocSize);
|
assert(pCmd->payloadLen + minMsgSize() <= pCmd->allocSize);
|
||||||
|
|
||||||
|
@ -1885,7 +1868,7 @@ static void doUpdateVgroupInfo(STableMeta *pTableMeta, SVgroupMsg *pVgroupMsg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doAddTableMetaLocalBuf(STableMeta* pTableMeta, STableMetaMsg* pMetaMsg, bool updateSTable) {
|
static void doAddTableMetaToLocalBuf(STableMeta* pTableMeta, STableMetaMsg* pMetaMsg, bool updateSTable) {
|
||||||
if (pTableMeta->tableType == TSDB_CHILD_TABLE) {
|
if (pTableMeta->tableType == TSDB_CHILD_TABLE) {
|
||||||
// add or update the corresponding super table meta data info
|
// add or update the corresponding super table meta data info
|
||||||
int32_t len = (int32_t) strnlen(pTableMeta->sTableName, TSDB_TABLE_FNAME_LEN);
|
int32_t len = (int32_t) strnlen(pTableMeta->sTableName, TSDB_TABLE_FNAME_LEN);
|
||||||
|
@ -1928,7 +1911,7 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
|
||||||
tNameExtractFullName(&pTableMetaInfo->name, name);
|
tNameExtractFullName(&pTableMetaInfo->name, name);
|
||||||
assert(strncmp(pMetaMsg->tableFname, name, tListLen(pMetaMsg->tableFname)) == 0);
|
assert(strncmp(pMetaMsg->tableFname, name, tListLen(pMetaMsg->tableFname)) == 0);
|
||||||
|
|
||||||
doAddTableMetaLocalBuf(pTableMeta, pMetaMsg, true);
|
doAddTableMetaToLocalBuf(pTableMeta, pMetaMsg, true);
|
||||||
doUpdateVgroupInfo(pTableMeta, &pMetaMsg->vgroup);
|
doUpdateVgroupInfo(pTableMeta, &pMetaMsg->vgroup);
|
||||||
|
|
||||||
tscDebug("0x%"PRIx64" recv table meta, uid:%" PRIu64 ", tid:%d, name:%s", pSql->self, pTableMeta->id.uid, pTableMeta->id.tid,
|
tscDebug("0x%"PRIx64" recv table meta, uid:%" PRIu64 ", tid:%d, name:%s", pSql->self, pTableMeta->id.uid, pTableMeta->id.tid,
|
||||||
|
@ -2039,7 +2022,7 @@ int tscProcessMultiTableMetaRsp(SSqlObj *pSql) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the tableMeta and add it into the TableMeta map
|
// create the tableMeta and add it into the TableMeta map
|
||||||
doAddTableMetaLocalBuf(pTableMeta, pMetaMsg, addToBuf);
|
doAddTableMetaToLocalBuf(pTableMeta, pMetaMsg, addToBuf);
|
||||||
|
|
||||||
// if the vgroup is not updated in current process, update it.
|
// if the vgroup is not updated in current process, update it.
|
||||||
int64_t vgId = pMetaMsg->vgroup.vgId;
|
int64_t vgId = pMetaMsg->vgroup.vgId;
|
||||||
|
@ -2051,7 +2034,7 @@ int tscProcessMultiTableMetaRsp(SSqlObj *pSql) {
|
||||||
pMsg += pMetaMsg->contLen;
|
pMsg += pMetaMsg->contLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pMultiMeta->numOfVgroup > 0) {
|
for(int32_t i = 0; i < pMultiMeta->numOfVgroup; ++i) {
|
||||||
char* name = pMsg;
|
char* name = pMsg;
|
||||||
pMsg += TSDB_TABLE_NAME_LEN;
|
pMsg += TSDB_TABLE_NAME_LEN;
|
||||||
|
|
||||||
|
@ -2059,15 +2042,13 @@ int tscProcessMultiTableMetaRsp(SSqlObj *pSql) {
|
||||||
assert(p != NULL);
|
assert(p != NULL);
|
||||||
|
|
||||||
int32_t size = 0;
|
int32_t size = 0;
|
||||||
SVgroupsInfo* pVgroupInfo = createVgroupInfoFromMsg(pMsg, &size, pSql->self);
|
p->pVgroupInfo = createVgroupInfoFromMsg(pMsg, &size, pSql->self);
|
||||||
|
|
||||||
p->pVgroupInfo = pVgroupInfo;
|
|
||||||
pMsg += size;
|
pMsg += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
pSql->res.code = TSDB_CODE_SUCCESS;
|
pSql->res.code = TSDB_CODE_SUCCESS;
|
||||||
pSql->res.numOfTotal = pMultiMeta->numOfTables;
|
pSql->res.numOfTotal = pMultiMeta->numOfTables;
|
||||||
tscDebug("0x%"PRIx64" load multi-tableMeta resp from complete numOfTables:%d", pSql->self, pMultiMeta->numOfTables);
|
tscDebug("0x%"PRIx64" load multi-tableMeta from mnode, numOfTables:%d", pSql->self, pMultiMeta->numOfTables);
|
||||||
|
|
||||||
taosHashCleanup(pSet);
|
taosHashCleanup(pSet);
|
||||||
taosReleaseRef(tscObjRef, pParentSql->self);
|
taosReleaseRef(tscObjRef, pParentSql->self);
|
||||||
|
@ -2471,7 +2452,7 @@ int32_t getMultiTableMetaFromMnode(SSqlObj *pSql, SArray* pNameList, SArray* pVg
|
||||||
for(int32_t i = 0; i < numOfVgroupList; ++i) {
|
for(int32_t i = 0; i < numOfVgroupList; ++i) {
|
||||||
char* name = taosArrayGetP(pVgroupNameList, i);
|
char* name = taosArrayGetP(pVgroupNameList, i);
|
||||||
if (i < numOfVgroupList - 1) {
|
if (i < numOfVgroupList - 1) {
|
||||||
len = sprintf(start, "%s, ", name);
|
len = sprintf(start, "%s,", name);
|
||||||
} else {
|
} else {
|
||||||
len = sprintf(start, "%s", name);
|
len = sprintf(start, "%s", name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -833,9 +833,9 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
|
||||||
case TSDB_DATA_TYPE_NCHAR: {
|
case TSDB_DATA_TYPE_NCHAR: {
|
||||||
int32_t charLen = varDataLen((char*)row[i] - VARSTR_HEADER_SIZE);
|
int32_t charLen = varDataLen((char*)row[i] - VARSTR_HEADER_SIZE);
|
||||||
if (fields[i].type == TSDB_DATA_TYPE_BINARY) {
|
if (fields[i].type == TSDB_DATA_TYPE_BINARY) {
|
||||||
assert(charLen <= fields[i].bytes);
|
assert(charLen <= fields[i].bytes && charLen >= 0);
|
||||||
} else {
|
} else {
|
||||||
assert(charLen <= fields[i].bytes * TSDB_NCHAR_SIZE);
|
assert(charLen <= fields[i].bytes * TSDB_NCHAR_SIZE && charLen >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(str + len, row[i], charLen);
|
memcpy(str + len, row[i], charLen);
|
||||||
|
|
|
@ -587,7 +587,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
|
||||||
pTableMetaInfo->pVgroupTables = pSupporter->pVgroupTables;
|
pTableMetaInfo->pVgroupTables = pSupporter->pVgroupTables;
|
||||||
|
|
||||||
pSupporter->exprList = NULL;
|
pSupporter->exprList = NULL;
|
||||||
pSupporter->colList = NULL;
|
pSupporter->colList = NULL;
|
||||||
pSupporter->pVgroupTables = NULL;
|
pSupporter->pVgroupTables = NULL;
|
||||||
memset(&pSupporter->fieldsInfo, 0, sizeof(SFieldInfo));
|
memset(&pSupporter->fieldsInfo, 0, sizeof(SFieldInfo));
|
||||||
memset(&pSupporter->groupInfo, 0, sizeof(SGroupbyExpr));
|
memset(&pSupporter->groupInfo, 0, sizeof(SGroupbyExpr));
|
||||||
|
@ -597,8 +597,6 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
|
||||||
* during the timestamp intersection.
|
* during the timestamp intersection.
|
||||||
*/
|
*/
|
||||||
pSupporter->limit = pQueryInfo->limit;
|
pSupporter->limit = pQueryInfo->limit;
|
||||||
// pQueryInfo->limit = pSupporter->limit;
|
|
||||||
|
|
||||||
SColumnIndex index = {.tableIndex = 0, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX};
|
SColumnIndex index = {.tableIndex = 0, .columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX};
|
||||||
SSchema* s = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, 0);
|
SSchema* s = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, 0);
|
||||||
|
|
||||||
|
@ -606,6 +604,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
|
||||||
int16_t funcId = pExpr->base.functionId;
|
int16_t funcId = pExpr->base.functionId;
|
||||||
|
|
||||||
// add the invisible timestamp column
|
// add the invisible timestamp column
|
||||||
|
printf("--------read:%p\n", pExpr);
|
||||||
if ((pExpr->base.colInfo.colId != PRIMARYKEY_TIMESTAMP_COL_INDEX) ||
|
if ((pExpr->base.colInfo.colId != PRIMARYKEY_TIMESTAMP_COL_INDEX) ||
|
||||||
(funcId != TSDB_FUNC_TS && funcId != TSDB_FUNC_TS_DUMMY && funcId != TSDB_FUNC_PRJ)) {
|
(funcId != TSDB_FUNC_TS && funcId != TSDB_FUNC_TS_DUMMY && funcId != TSDB_FUNC_PRJ)) {
|
||||||
|
|
||||||
|
@ -645,11 +644,11 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
subquerySetState(pPrevSub, &pSql->subState, i, 0);
|
subquerySetState(pNew, &pSql->subState, i, 0);
|
||||||
|
|
||||||
size_t numOfCols = taosArrayGetSize(pQueryInfo->colList);
|
size_t numOfCols = taosArrayGetSize(pQueryInfo->colList);
|
||||||
tscDebug("0x%"PRIx64" subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%" PRIzu ", colList:%" PRIzu ", fieldsInfo:%d, name:%s",
|
tscDebug("0x%"PRIx64" subquery:0x%"PRIx64" tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%" PRIzu ", colList:%" PRIzu ", fieldsInfo:%d, name:%s",
|
||||||
pSql->self, pNew, 0, pTableMetaInfo->vgroupIndex, pQueryInfo->type, taosArrayGetSize(pQueryInfo->exprList),
|
pSql->self, pNew->self, 0, pTableMetaInfo->vgroupIndex, pQueryInfo->type, taosArrayGetSize(pQueryInfo->exprList),
|
||||||
numOfCols, pQueryInfo->fieldsInfo.numOfOutput, tNameGetTableName(&pTableMetaInfo->name));
|
numOfCols, pQueryInfo->fieldsInfo.numOfOutput, tNameGetTableName(&pTableMetaInfo->name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -712,8 +711,6 @@ static int32_t quitAllSubquery(SSqlObj* pSqlSub, SSqlObj* pSqlObj, SJoinSupporte
|
||||||
static void updateQueryTimeRange(SQueryInfo* pQueryInfo, STimeWindow* win) {
|
static void updateQueryTimeRange(SQueryInfo* pQueryInfo, STimeWindow* win) {
|
||||||
assert(pQueryInfo->window.skey <= win->skey && pQueryInfo->window.ekey >= win->ekey);
|
assert(pQueryInfo->window.skey <= win->skey && pQueryInfo->window.ekey >= win->ekey);
|
||||||
pQueryInfo->window = *win;
|
pQueryInfo->window = *win;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tidTagsCompar(const void* p1, const void* p2) {
|
int32_t tidTagsCompar(const void* p1, const void* p2) {
|
||||||
|
@ -809,8 +806,10 @@ static void issueTsCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj*
|
||||||
assert(pQueryInfo->numOfTables == 1);
|
assert(pQueryInfo->numOfTables == 1);
|
||||||
|
|
||||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||||
|
STimeWindow window = pQueryInfo->window;
|
||||||
tscInitQueryInfo(pQueryInfo);
|
tscInitQueryInfo(pQueryInfo);
|
||||||
|
|
||||||
|
pQueryInfo->window = window;
|
||||||
TSDB_QUERY_CLEAR_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_TAG_FILTER_QUERY);
|
TSDB_QUERY_CLEAR_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_TAG_FILTER_QUERY);
|
||||||
TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_MULTITABLE_QUERY);
|
TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_MULTITABLE_QUERY);
|
||||||
|
|
||||||
|
@ -1285,7 +1284,6 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
|
||||||
|
|
||||||
if (pSupporter->f == NULL) {
|
if (pSupporter->f == NULL) {
|
||||||
tscError("0x%"PRIx64" failed to create tmp file:%s, reason:%s", pSql->self, pSupporter->path, strerror(errno));
|
tscError("0x%"PRIx64" failed to create tmp file:%s, reason:%s", pSql->self, pSupporter->path, strerror(errno));
|
||||||
|
|
||||||
pParentSql->res.code = TAOS_SYSTEM_ERROR(errno);
|
pParentSql->res.code = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
|
||||||
if (quitAllSubquery(pSql, pParentSql, pSupporter)) {
|
if (quitAllSubquery(pSql, pParentSql, pSupporter)) {
|
||||||
|
@ -1407,7 +1405,6 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR
|
||||||
}
|
}
|
||||||
|
|
||||||
tscAsyncResultOnError(pParentSql);
|
tscAsyncResultOnError(pParentSql);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1640,7 +1637,6 @@ void tscFetchDatablockForSubquery(SSqlObj* pSql) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SSqlRes* pRes1 = &pSql1->res;
|
SSqlRes* pRes1 = &pSql1->res;
|
||||||
|
|
||||||
if (pRes1->row >= pRes1->numOfRows) {
|
if (pRes1->row >= pRes1->numOfRows) {
|
||||||
subquerySetState(pSql1, &pSql->subState, i, 0);
|
subquerySetState(pSql1, &pSql->subState, i, 0);
|
||||||
}
|
}
|
||||||
|
@ -1726,8 +1722,8 @@ void tscSetupOutputColumnIndex(SSqlObj* pSql) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore the offset value for super table query in case of final result.
|
// restore the offset value for super table query in case of final result.
|
||||||
tscRestoreFuncForSTableQuery(pQueryInfo);
|
// tscRestoreFuncForSTableQuery(pQueryInfo);
|
||||||
tscFieldInfoUpdateOffset(pQueryInfo);
|
// tscFieldInfoUpdateOffset(pQueryInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
|
void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code) {
|
||||||
|
@ -1847,12 +1843,6 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
|
||||||
SQueryInfo *pNewQueryInfo = tscGetQueryInfo(&pNew->cmd);
|
SQueryInfo *pNewQueryInfo = tscGetQueryInfo(&pNew->cmd);
|
||||||
assert(pNewQueryInfo != NULL);
|
assert(pNewQueryInfo != NULL);
|
||||||
|
|
||||||
// update the table index
|
|
||||||
// size_t num = taosArrayGetSize(pNewQueryInfo->colList);
|
|
||||||
// for (int32_t i = 0; i < num; ++i) {
|
|
||||||
// SColumn* pCol = taosArrayGetP(pNewQueryInfo->colList, i);
|
|
||||||
// }
|
|
||||||
|
|
||||||
pSupporter->colList = pNewQueryInfo->colList;
|
pSupporter->colList = pNewQueryInfo->colList;
|
||||||
pNewQueryInfo->colList = NULL;
|
pNewQueryInfo->colList = NULL;
|
||||||
|
|
||||||
|
@ -1883,7 +1873,10 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
|
||||||
// backup the data and clear it in the sqlcmd object
|
// backup the data and clear it in the sqlcmd object
|
||||||
memset(&pNewQueryInfo->groupbyExpr, 0, sizeof(SGroupbyExpr));
|
memset(&pNewQueryInfo->groupbyExpr, 0, sizeof(SGroupbyExpr));
|
||||||
|
|
||||||
|
STimeWindow range = pNewQueryInfo->window;
|
||||||
tscInitQueryInfo(pNewQueryInfo);
|
tscInitQueryInfo(pNewQueryInfo);
|
||||||
|
|
||||||
|
pNewQueryInfo->window = range;
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pNewQueryInfo, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pNewQueryInfo, 0);
|
||||||
|
|
||||||
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { // return the tableId & tag
|
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { // return the tableId & tag
|
||||||
|
@ -3270,7 +3263,7 @@ static void doBuildResFromSubqueries(SSqlObj* pSql) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tscRestoreFuncForSTableQuery(pQueryInfo);
|
// tscRestoreFuncForSTableQuery(pQueryInfo);
|
||||||
int32_t rowSize = tscGetResRowLength(pQueryInfo->exprList);
|
int32_t rowSize = tscGetResRowLength(pQueryInfo->exprList);
|
||||||
|
|
||||||
assert(numOfRes * rowSize > 0);
|
assert(numOfRes * rowSize > 0);
|
||||||
|
@ -3362,8 +3355,6 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) {
|
||||||
tscAsyncResultOnError(pSql);
|
tscAsyncResultOnError(pSql);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tscRestoreFuncForSTableQuery(pQueryInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert (pRes->row >= pRes->numOfRows);
|
assert (pRes->row >= pRes->numOfRows);
|
||||||
|
|
|
@ -1077,16 +1077,16 @@ void tscFreeQueryInfo(SSqlCmd* pCmd, bool removeMeta) {
|
||||||
|
|
||||||
int32_t numOfUpstream = taosArrayGetSize(pQueryInfo->pUpstream);
|
int32_t numOfUpstream = taosArrayGetSize(pQueryInfo->pUpstream);
|
||||||
for(int32_t i = 0; i < numOfUpstream; ++i) {
|
for(int32_t i = 0; i < numOfUpstream; ++i) {
|
||||||
SQueryInfo* pUp = taosArrayGetP(pQueryInfo->pUpstream, i);
|
SQueryInfo* pUpQueryInfo = taosArrayGetP(pQueryInfo->pUpstream, i);
|
||||||
freeQueryInfoImpl(pUp);
|
freeQueryInfoImpl(pUpQueryInfo);
|
||||||
|
|
||||||
clearAllTableMetaInfo(pUp, removeMeta);
|
clearAllTableMetaInfo(pUpQueryInfo, removeMeta);
|
||||||
if (pUp->pQInfo != NULL) {
|
if (pUpQueryInfo->pQInfo != NULL) {
|
||||||
qDestroyQueryInfo(pUp->pQInfo);
|
qDestroyQueryInfo(pUpQueryInfo->pQInfo);
|
||||||
pUp->pQInfo = NULL;
|
pUpQueryInfo->pQInfo = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tfree(pUp);
|
tfree(pUpQueryInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
freeQueryInfoImpl(pQueryInfo);
|
freeQueryInfoImpl(pQueryInfo);
|
||||||
|
@ -1134,8 +1134,17 @@ void tscResetSqlCmd(SSqlCmd* pCmd, bool removeMeta) {
|
||||||
pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks);
|
pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks);
|
||||||
tscFreeQueryInfo(pCmd, removeMeta);
|
tscFreeQueryInfo(pCmd, removeMeta);
|
||||||
|
|
||||||
taosHashCleanup(pCmd->pTableMetaMap);
|
if (pCmd->pTableMetaMap != NULL) {
|
||||||
pCmd->pTableMetaMap = NULL;
|
STableMetaVgroupInfo* p = taosHashIterate(pCmd->pTableMetaMap, NULL);
|
||||||
|
while (p) {
|
||||||
|
tfree(p->pVgroupInfo);
|
||||||
|
tfree(p->pTableMeta);
|
||||||
|
p = taosHashIterate(pCmd->pTableMetaMap, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosHashCleanup(pCmd->pTableMetaMap);
|
||||||
|
pCmd->pTableMetaMap = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscFreeSqlResult(SSqlObj* pSql) {
|
void tscFreeSqlResult(SSqlObj* pSql) {
|
||||||
|
@ -1189,7 +1198,6 @@ void tscFreeRegisteredSqlObj(void *pSql) {
|
||||||
tscDebug("0x%"PRIx64" free SqlObj, total in tscObj:%d, total:%d", p->self, num, total);
|
tscDebug("0x%"PRIx64" free SqlObj, total in tscObj:%d, total:%d", p->self, num, total);
|
||||||
tscFreeSqlObj(p);
|
tscFreeSqlObj(p);
|
||||||
taosReleaseRef(tscRefId, pTscObj->rid);
|
taosReleaseRef(tscRefId, pTscObj->rid);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscFreeMetaSqlObj(int64_t *rid){
|
void tscFreeMetaSqlObj(int64_t *rid){
|
||||||
|
@ -1725,16 +1733,14 @@ SInternalField* tscFieldInfoInsert(SFieldInfo* pFieldInfo, int32_t index, TAOS_F
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscFieldInfoUpdateOffset(SQueryInfo* pQueryInfo) {
|
void tscFieldInfoUpdateOffset(SQueryInfo* pQueryInfo) {
|
||||||
|
int32_t offset = 0;
|
||||||
size_t numOfExprs = tscNumOfExprs(pQueryInfo);
|
size_t numOfExprs = tscNumOfExprs(pQueryInfo);
|
||||||
|
|
||||||
SExprInfo* pExpr = taosArrayGetP(pQueryInfo->exprList, 0);
|
for (int32_t i = 0; i < numOfExprs; ++i) {
|
||||||
pExpr->base.offset = 0;
|
|
||||||
|
|
||||||
for (int32_t i = 1; i < numOfExprs; ++i) {
|
|
||||||
SExprInfo* prev = taosArrayGetP(pQueryInfo->exprList, i - 1);
|
|
||||||
SExprInfo* p = taosArrayGetP(pQueryInfo->exprList, i);
|
SExprInfo* p = taosArrayGetP(pQueryInfo->exprList, i);
|
||||||
|
|
||||||
p->base.offset = prev->base.offset + prev->base.resBytes;
|
p->base.offset = offset;
|
||||||
|
offset += p->base.resBytes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1842,6 +1848,7 @@ void* sqlExprDestroy(SExprInfo* pExpr) {
|
||||||
tExprTreeDestroy(pExpr->pExpr, NULL);
|
tExprTreeDestroy(pExpr->pExpr, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("free---------------%p\n", pExpr);
|
||||||
tfree(pExpr);
|
tfree(pExpr);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1911,6 +1918,7 @@ SExprInfo* tscExprCreate(SQueryInfo* pQueryInfo, int16_t functionId, SColumnInde
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("malloc======================%p\n", pExpr);
|
||||||
SSqlExpr* p = &pExpr->base;
|
SSqlExpr* p = &pExpr->base;
|
||||||
p->functionId = functionId;
|
p->functionId = functionId;
|
||||||
|
|
||||||
|
@ -2066,8 +2074,6 @@ int32_t tscExprCopy(SArray* dst, const SArray* src, uint64_t uid, bool deepcopy)
|
||||||
} else {
|
} else {
|
||||||
taosArrayPush(dst, &pExpr);
|
taosArrayPush(dst, &pExpr);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
taosArrayPush(dst, &pExpr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3953,12 +3959,22 @@ uint32_t tscGetTableMetaMaxSize() {
|
||||||
|
|
||||||
STableMeta* tscTableMetaDup(STableMeta* pTableMeta) {
|
STableMeta* tscTableMetaDup(STableMeta* pTableMeta) {
|
||||||
assert(pTableMeta != NULL);
|
assert(pTableMeta != NULL);
|
||||||
uint32_t size = tscGetTableMetaSize(pTableMeta);
|
size_t size = tscGetTableMetaSize(pTableMeta);
|
||||||
|
|
||||||
STableMeta* p = calloc(1, size);
|
STableMeta* p = calloc(1, size);
|
||||||
memcpy(p, pTableMeta, size);
|
memcpy(p, pTableMeta, size);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SVgroupsInfo* tscVgroupsInfoDup(SVgroupsInfo* pVgroupsInfo) {
|
||||||
|
assert(pVgroupsInfo != NULL);
|
||||||
|
|
||||||
|
size_t size = sizeof(SVgroupInfo) * pVgroupsInfo->numOfVgroups + sizeof(SVgroupsInfo);
|
||||||
|
SVgroupsInfo* pInfo = calloc(1, size);
|
||||||
|
memcpy(pInfo, pVgroupsInfo, size);
|
||||||
|
return pInfo;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t createProjectionExpr(SQueryInfo* pQueryInfo, STableMetaInfo* pTableMetaInfo, SExprInfo*** pExpr, int32_t* num) {
|
int32_t createProjectionExpr(SQueryInfo* pQueryInfo, STableMetaInfo* pTableMetaInfo, SExprInfo*** pExpr, int32_t* num) {
|
||||||
if (!pQueryInfo->arithmeticOnAgg) {
|
if (!pQueryInfo->arithmeticOnAgg) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -2922,7 +2922,7 @@ static int32_t mnodeProcessMultiTableMetaMsg(SMnodeMsg *pMsg) {
|
||||||
char* msg = (char*) pMultiMeta + pMultiMeta->contLen;
|
char* msg = (char*) pMultiMeta + pMultiMeta->contLen;
|
||||||
|
|
||||||
// add the additional super table names that needs the vgroup info
|
// add the additional super table names that needs the vgroup info
|
||||||
for(;t < pInfo->numOfVgroups; ++t) {
|
for(;t < num; ++t) {
|
||||||
taosArrayPush(pList, &nameList[t]);
|
taosArrayPush(pList, &nameList[t]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7135,7 +7135,7 @@ void* destroyQueryFuncExpr(SExprInfo* pExprInfo, int32_t numOfExpr) {
|
||||||
|
|
||||||
void* freeColumnInfo(SColumnInfo* pColumnInfo, int32_t numOfCols) {
|
void* freeColumnInfo(SColumnInfo* pColumnInfo, int32_t numOfCols) {
|
||||||
if (pColumnInfo != NULL) {
|
if (pColumnInfo != NULL) {
|
||||||
assert(numOfCols > 0);
|
assert(numOfCols >= 0);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfCols; i++) {
|
for (int32_t i = 0; i < numOfCols; i++) {
|
||||||
freeColumnFilterInfo(pColumnInfo[i].flist.filterInfo, pColumnInfo[i].flist.numOfFilters);
|
freeColumnFilterInfo(pColumnInfo[i].flist.filterInfo, pColumnInfo[i].flist.numOfFilters);
|
||||||
|
|
|
@ -148,6 +148,7 @@ int32_t taosHashGetMaxOverflowLinkLength(const SHashObj *pHashObj);
|
||||||
size_t taosHashGetMemSize(const SHashObj *pHashObj);
|
size_t taosHashGetMemSize(const SHashObj *pHashObj);
|
||||||
|
|
||||||
void *taosHashIterate(SHashObj *pHashObj, void *p);
|
void *taosHashIterate(SHashObj *pHashObj, void *p);
|
||||||
|
|
||||||
void taosHashCancelIterate(SHashObj *pHashObj, void *p);
|
void taosHashCancelIterate(SHashObj *pHashObj, void *p);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
Loading…
Reference in New Issue