Merge branch 'develop' into xiaoping/add_test_case

This commit is contained in:
Ping Xiao 2020-10-19 13:07:41 +08:00
commit 608f9b86ce
4 changed files with 39 additions and 5 deletions

View File

@ -566,7 +566,7 @@ int tdSetKVRowDataOfCol(SKVRow *orow, int16_t colId, int8_t type, void *value) {
SKVRow nrow = NULL;
void * ptr = taosbsearch(&colId, kvRowColIdx(row), kvRowNCols(row), sizeof(SColIdx), comparTagId, TD_GE);
if (ptr == NULL || ((SColIdx *)ptr)->colId < colId) { // need to add a column value to the row
if (ptr == NULL || ((SColIdx *)ptr)->colId > colId) { // need to add a column value to the row
int diff = IS_VAR_DATA_TYPE(type) ? varDataTLen(value) : TYPE_BYTES[type];
nrow = malloc(kvRowLen(row) + sizeof(SColIdx) + diff);
if (nrow == NULL) return -1;

View File

@ -2224,16 +2224,20 @@ void mnodeDropAllChildTablesInVgroups(SVgObj *pVgroup) {
void mnodeDropAllChildTables(SDbObj *pDropDb) {
void * pIter = NULL;
int32_t numOfTables = 0;
int32_t dbNameLen = strlen(pDropDb->name);
SChildTableObj *pTable = NULL;
char prefix[64] = {0};
tstrncpy(prefix, pDropDb->name, 64);
strcat(prefix, TS_PATH_DELIMITER);
int32_t prefixLen = strlen(prefix);
mInfo("db:%s, all child tables will be dropped from sdb", pDropDb->name);
while (1) {
pIter = mnodeGetNextChildTable(pIter, &pTable);
if (pTable == NULL) break;
if (strncmp(pDropDb->name, pTable->info.tableId, dbNameLen) == 0) {
if (strncmp(prefix, pTable->info.tableId, prefixLen) == 0) {
SSdbOper oper = {
.type = SDB_OPER_LOCAL,
.table = tsChildTableSdb,

View File

@ -185,11 +185,18 @@ enum {
QUERY_RESULT_READY = 2,
};
typedef struct SMemRef {
int32_t ref;
void *mem;
void *imem;
} SMemRef;
typedef struct SQInfo {
void* signature;
int32_t code; // error code to returned to client
int64_t owner; // if it is in execution
void* tsdb;
SMemRef memRef;
int32_t vgId;
STableGroupInfo tableGroupInfo; // table <tid, last_key> list SArray<STableKeyInfo>
STableGroupInfo tableqinfoGroupInfo; // this is a group array list, including SArray<STableQueryInfo*> structure

View File

@ -20,6 +20,7 @@
#include "exception.h"
#include "../../query/inc/qAst.h" // todo move to common module
#include "../../query/inc/qExecutor.h" // todo move to common module
#include "tlosertree.h"
#include "tsdb.h"
#include "tsdbMain.h"
@ -143,6 +144,7 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey,
STsdbQueryHandle* pQueryHandle);
static int tsdbCheckInfoCompar(const void* key1, const void* key2);
static void tsdbInitDataBlockLoadInfo(SDataBlockLoadInfo* pBlockLoadInfo) {
pBlockLoadInfo->slot = -1;
pBlockLoadInfo->tid = -1;
@ -182,6 +184,27 @@ static SArray* getDefaultLoadColumns(STsdbQueryHandle* pQueryHandle, bool loadTS
return pLocalIdList;
}
static void tsdbMayTakeMemSnapshot(TsdbQueryHandleT pHandle) {
STsdbQueryHandle* pSecQueryHandle = (STsdbQueryHandle*) pHandle;
SQInfo *pQInfo = (SQInfo *)(pSecQueryHandle->qinfo);
if (pQInfo->memRef.ref++ == 0) {
tsdbTakeMemSnapshot(pSecQueryHandle->pTsdb, &pSecQueryHandle->mem, &pSecQueryHandle->imem);
pQInfo->memRef.mem = pSecQueryHandle->mem;
pQInfo->memRef.imem = pSecQueryHandle->imem;
} else {
pSecQueryHandle->mem = (SMemTable *)(pQInfo->memRef.mem);
pSecQueryHandle->imem = (SMemTable *)(pQInfo->memRef.imem);
}
}
static void tsdbMayUnTakeMemSnapshot(TsdbQueryHandleT pHandle) {
STsdbQueryHandle* pSecQueryHandle = (STsdbQueryHandle*) pHandle;
SQInfo *pQInfo = (SQInfo *)(pSecQueryHandle->qinfo);
if (--pQInfo->memRef.ref == 0) {
tsdbUnTakeMemSnapShot(pSecQueryHandle->pTsdb, pSecQueryHandle->mem, pSecQueryHandle->imem);
}
}
static SArray* createCheckInfoFromTableGroup(STsdbQueryHandle* pQueryHandle, STableGroupInfo* pGroupList, STsdbMeta* pMeta) {
size_t sizeOfGroup = taosArrayGetSize(pGroupList->pGroupList);
assert(sizeOfGroup >= 1 && pMeta != NULL);
@ -270,7 +293,7 @@ static STsdbQueryHandle* tsdbQueryTablesImpl(TSDB_REPO_T* tsdb, STsdbQueryCond*
goto out_of_memory;
}
tsdbTakeMemSnapshot(pQueryHandle->pTsdb, &pQueryHandle->mem, &pQueryHandle->imem);
tsdbMayTakeMemSnapshot(pQueryHandle);
assert(pCond != NULL && pCond->numOfCols > 0);
if (ASCENDING_TRAVERSE(pCond->order)) {
@ -2701,7 +2724,7 @@ void tsdbCleanupQueryHandle(TsdbQueryHandleT queryHandle) {
taosTFree(pQueryHandle->statis);
// todo check error
tsdbUnTakeMemSnapShot(pQueryHandle->pTsdb, pQueryHandle->mem, pQueryHandle->imem);
tsdbMayUnTakeMemSnapshot(pQueryHandle);
tsdbDestroyHelper(&pQueryHandle->rhelper);