Merge branch '3.0' into enh/TS-5111-3.0
This commit is contained in:
commit
964ee72932
|
@ -72,7 +72,7 @@ SELECT _wstart, count(*), avg(voltage) FROM power.meters PARTITION BY tbname INT
|
|||
- stb_name 是保存计算结果的超级表的表名,如果该超级表不存在,则会自动创建;如果已存在,则检查列的 schema 信息。详见 6.3.8 节。
|
||||
- tags 子句定义了流计算中创建标签的规则。通过 tags 字段可以为每个分区对应的子表生成自定义的标签值。
|
||||
|
||||
## 流试计算的规则和策略
|
||||
## 流式计算的规则和策略
|
||||
|
||||
### 流计算的分区
|
||||
|
||||
|
|
|
@ -229,4 +229,12 @@ toc_max_heading_level: 4
|
|||
- 权限
|
||||
- 白名单
|
||||
|
||||
。
|
||||

|
||||
|
||||
### 慢 SQL
|
||||
点击“系统管理”后,点击“慢 SQL”标签页,可以查看慢 SQL 执行语句日志统计与明细。
|
||||
|
||||
- 慢 SQL 明细:默认展示的是开始执行时间是一天内和执行耗时大于等于10秒的数据
|
||||

|
||||
- 慢 SQL 统计:默认展示所有的数据,可根据开始执行时间进行过滤
|
||||

|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 283 KiB |
Binary file not shown.
After Width: | Height: | Size: 256 KiB |
|
@ -54,7 +54,7 @@ window_clause: {
|
|||
```
|
||||
|
||||
其中,interval_val 和 sliding_val 都表示时间段,interval_offset 表示窗口偏移量,interval_offset 必须小于 interval_val,语法上支持三种方式,举例说明如下:
|
||||
- INTERVAL(1s, 500a) SLIDING(1s), 自带时间单位的形式,其中的时间单位是单字符表示, 分别为: a (毫秒), b (纳秒), d (天), h (小时), m (分钟), n (月), s (秒), u (微妙), w (周), y (年).
|
||||
- INTERVAL(1s, 500a) SLIDING(1s), 自带时间单位的形式,其中的时间单位是单字符表示, 分别为: a (毫秒), b (纳秒), d (天), h (小时), m (分钟), n (月), s (秒), u (微秒), w (周), y (年).
|
||||
- INTERVAL(1000, 500) SLIDING(1000), 不带时间单位的形式,将使用查询库的时间精度作为默认时间单位,当存在多个库时默认采用精度更高的库.
|
||||
- INTERVAL('1s', '500a') SLIDING('1s'), 自带时间单位的字符串形式,字符串内部不能有任何空格等其它字符.
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ time_duration:
|
|||
number unit
|
||||
```
|
||||
|
||||
创建 TSMA 时需要指定 TSMA 名字, 表名字, 函数列表以及窗口大小. 当基于一个已经存在的 TSMA 创建新的 TSMA 时, 需要使用 `RECURSIVE` 关键字但不能指定 `FUNCTION()`, 新创建的 TSMA 已有 TSMA 拥有相同的函数列表, 且此种情况下所指定的 INTERVAL 必须为所基于的 TSMA 窗口长度的整数倍。
|
||||
创建 TSMA 时需要指定 TSMA 名字, 表名字, 函数列表以及窗口大小. 当基于一个已经存在的 TSMA 创建新的 TSMA 时, 需要使用 `RECURSIVE` 关键字但不能指定 `FUNCTION()`, 新创建的 TSMA 已有 TSMA 拥有相同的函数列表, 且此种情况下所指定的 INTERVAL 必须至少为所基于的 TSMA 窗口长度的整数倍, 并且天不能基于2h或3h建立, 只能基于1h建立, 月也只能基于1d而非2d,3d建立。
|
||||
|
||||
其中 TSMA 命名规则与表名字类似, 长度最大限制为表名长度限制减去输出表后缀长度, 表名长度限制为193, 输出表后缀为`_tsma_res_stb_`, TSMA 名字最大长度为178.
|
||||
|
||||
|
@ -28,7 +28,7 @@ TSMA只能基于超级表和普通表创建, 不能基于子表创建.
|
|||
|
||||
由于TSMA输出为一张超级表, 因此输出表的行长度受最大行长度限制, 不同函数的`中间结果`大小各异, 一般都大于原始数据大小, 若输出表的行长度大于最大行长度限制, 将会报`Row length exceeds max length`错误. 此时需要减少函数个数或者将常用的函数进行分组拆分到多个TSMA中.
|
||||
|
||||
窗口大小的限制为[1m ~ 1h]. INTERVAL 的单位与查询中INTERVAL子句相同, 如 a (毫秒), b (纳秒), h (小时), m (分钟), s (秒), u (微妙).
|
||||
窗口大小的限制为[1m ~ 1y/12n]. INTERVAL 的单位与查询中INTERVAL子句相同, 如 a (毫秒), b (纳秒), h (小时), m (分钟), s (秒), u (微妙), d (天), w(周), n(月), y(年).
|
||||
|
||||
TSMA为库内对象, 但名字全局唯一. 集群内一共可创建TSMA个数受参数`maxTsmaNum`限制, 参数默认值为3, 范围: [0-3]. 注意, 由于TSMA后台计算使用流计算, 因此每创建一条TSMA, 将会创建一条流, 因此能够创建的TSMA条数也受当前已经存在的流条数和最大可创建流条数限制.
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ typedef struct SStoreCacheReader {
|
|||
SArray *pFuncTypeList, SColumnInfo* pPkCol, int32_t numOfPks);
|
||||
void (*closeReader)(void *pReader);
|
||||
int32_t (*retrieveRows)(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, const int32_t *dstSlotIds,
|
||||
SArray *pTableUidList);
|
||||
SArray *pTableUidList, bool* pGotAllRows);
|
||||
int32_t (*reuseReader)(void *pReader, void *pTableIdList, int32_t numOfTables);
|
||||
} SStoreCacheReader;
|
||||
|
||||
|
|
|
@ -552,6 +552,9 @@ int32_t createRequest(uint64_t connId, int32_t type, int64_t reqid, SRequestObj
|
|||
(*pRequest)->allocatorRefId = -1;
|
||||
|
||||
(*pRequest)->pDb = getDbOfConnection(pTscObj);
|
||||
if (NULL == (*pRequest)->pDb) {
|
||||
TSC_ERR_JRET(terrno);
|
||||
}
|
||||
(*pRequest)->pTscObj = pTscObj;
|
||||
(*pRequest)->inCallback = false;
|
||||
(*pRequest)->msgBuf = taosMemoryCalloc(1, ERROR_MSG_BUF_DEFAULT_SIZE);
|
||||
|
|
|
@ -1359,6 +1359,14 @@ static void *hbThreadFunc(void *param) {
|
|||
pInfo->msgInfo.len = tlen;
|
||||
pInfo->msgType = TDMT_MND_HEARTBEAT;
|
||||
pInfo->param = taosMemoryMalloc(sizeof(int32_t));
|
||||
if (pInfo->param == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tFreeClientHbBatchReq(pReq);
|
||||
// hbClearReqInfo(pAppHbMgr);
|
||||
taosMemoryFree(buf);
|
||||
taosMemoryFree(pInfo);
|
||||
break;
|
||||
}
|
||||
*(int32_t *)pInfo->param = i;
|
||||
pInfo->paramFreeFp = taosMemoryFree;
|
||||
pInfo->requestId = generateRequestId();
|
||||
|
|
|
@ -1291,7 +1291,7 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue
|
|||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
pRequest->code = terrno;
|
||||
pRequest->code = code;
|
||||
}
|
||||
|
||||
if (res) {
|
||||
|
@ -1586,6 +1586,8 @@ int32_t taosConnectImpl(const char* user, const char* auth, const char* db, __ta
|
|||
pRequest->sqlstr = taosStrdup("taos_connect");
|
||||
if (pRequest->sqlstr) {
|
||||
pRequest->sqlLen = strlen(pRequest->sqlstr);
|
||||
} else {
|
||||
return terrno;
|
||||
}
|
||||
|
||||
SMsgSendInfo* body = NULL;
|
||||
|
@ -1649,6 +1651,9 @@ static int32_t buildConnectMsg(SRequestObj* pRequest, SMsgSendInfo** pMsgSendInf
|
|||
char* db = getDbOfConnection(pObj);
|
||||
if (db != NULL) {
|
||||
tstrncpy(connectReq.db, db, sizeof(connectReq.db));
|
||||
} else if (terrno) {
|
||||
taosMemoryFree(*pMsgSendInfo);
|
||||
return terrno;
|
||||
}
|
||||
taosMemoryFreeClear(db);
|
||||
|
||||
|
@ -2396,11 +2401,16 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
|
|||
}
|
||||
|
||||
char* getDbOfConnection(STscObj* pObj) {
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
char* p = NULL;
|
||||
(void)taosThreadMutexLock(&pObj->mutex);
|
||||
size_t len = strlen(pObj->db);
|
||||
if (len > 0) {
|
||||
p = strndup(pObj->db, tListLen(pObj->db));
|
||||
if (p == NULL) {
|
||||
tscError("failed to strndup db name");
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
(void)taosThreadMutexUnlock(&pObj->mutex);
|
||||
|
|
|
@ -186,7 +186,7 @@ int32_t tsdbCacherowsReaderOpen(void *pVnode, int32_t type, void *pTableIdList,
|
|||
SArray *pCidList, int32_t *pSlotIds, uint64_t suid, void **pReader, const char *idstr,
|
||||
SArray *pFuncTypeList, SColumnInfo *pkCol, int32_t numOfPks);
|
||||
int32_t tsdbRetrieveCacheRows(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, const int32_t *dstSlotIds,
|
||||
SArray *pTableUids);
|
||||
SArray *pTableUids, bool *pGotAllRows);
|
||||
void tsdbCacherowsReaderClose(void *pReader);
|
||||
|
||||
void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity);
|
||||
|
|
|
@ -260,7 +260,7 @@ void metaCloseTbCursor(SMTbCursor *pTbCur) {
|
|||
if (!pTbCur->paused) {
|
||||
metaReaderClear(&pTbCur->mr);
|
||||
if (pTbCur->pDbc) {
|
||||
(void)tdbTbcClose((TBC *)pTbCur->pDbc);
|
||||
tdbTbcClose((TBC *)pTbCur->pDbc);
|
||||
}
|
||||
}
|
||||
taosMemoryFree(pTbCur);
|
||||
|
@ -270,7 +270,7 @@ void metaCloseTbCursor(SMTbCursor *pTbCur) {
|
|||
void metaPauseTbCursor(SMTbCursor *pTbCur) {
|
||||
if (!pTbCur->paused) {
|
||||
metaReaderClear(&pTbCur->mr);
|
||||
(void)tdbTbcClose((TBC *)pTbCur->pDbc);
|
||||
tdbTbcClose((TBC *)pTbCur->pDbc);
|
||||
pTbCur->paused = 1;
|
||||
}
|
||||
}
|
||||
|
@ -463,7 +463,7 @@ void metaCloseCtbCursor(SMCtbCursor *pCtbCur) {
|
|||
if (!pCtbCur->paused) {
|
||||
if (pCtbCur->pMeta && pCtbCur->lock) metaULock(pCtbCur->pMeta);
|
||||
if (pCtbCur->pCur) {
|
||||
(void)tdbTbcClose(pCtbCur->pCur);
|
||||
tdbTbcClose(pCtbCur->pCur);
|
||||
}
|
||||
}
|
||||
tdbFree(pCtbCur->pKey);
|
||||
|
@ -474,7 +474,7 @@ void metaCloseCtbCursor(SMCtbCursor *pCtbCur) {
|
|||
|
||||
void metaPauseCtbCursor(SMCtbCursor *pCtbCur) {
|
||||
if (!pCtbCur->paused) {
|
||||
(void)tdbTbcClose((TBC *)pCtbCur->pCur);
|
||||
tdbTbcClose((TBC *)pCtbCur->pCur);
|
||||
if (pCtbCur->lock) {
|
||||
metaULock(pCtbCur->pMeta);
|
||||
}
|
||||
|
@ -582,7 +582,7 @@ void metaCloseStbCursor(SMStbCursor *pStbCur) {
|
|||
if (pStbCur) {
|
||||
if (pStbCur->pMeta) metaULock(pStbCur->pMeta);
|
||||
if (pStbCur->pCur) {
|
||||
(void)tdbTbcClose(pStbCur->pCur);
|
||||
tdbTbcClose(pStbCur->pCur);
|
||||
|
||||
tdbFree(pStbCur->pKey);
|
||||
tdbFree(pStbCur->pVal);
|
||||
|
@ -656,14 +656,14 @@ int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sv
|
|||
|
||||
if (tdbTbcMoveTo(pSkmDbC, &skmDbKey, sizeof(skmDbKey), &c) < 0) {
|
||||
metaULock(pMeta);
|
||||
(void)tdbTbcClose(pSkmDbC);
|
||||
tdbTbcClose(pSkmDbC);
|
||||
code = TSDB_CODE_NOT_FOUND;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
if (c == 0) {
|
||||
metaULock(pMeta);
|
||||
(void)tdbTbcClose(pSkmDbC);
|
||||
tdbTbcClose(pSkmDbC);
|
||||
code = TSDB_CODE_FAILED;
|
||||
metaError("meta/query: incorrect c: %" PRId32 ".", c);
|
||||
goto _exit;
|
||||
|
@ -679,7 +679,7 @@ int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sv
|
|||
|
||||
if (((SSkmDbKey *)pKey)->uid != skmDbKey.uid) {
|
||||
metaULock(pMeta);
|
||||
(void)tdbTbcClose(pSkmDbC);
|
||||
tdbTbcClose(pSkmDbC);
|
||||
code = TSDB_CODE_NOT_FOUND;
|
||||
goto _exit;
|
||||
}
|
||||
|
@ -687,7 +687,7 @@ int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sv
|
|||
sver = ((SSkmDbKey *)pKey)->sver;
|
||||
|
||||
metaULock(pMeta);
|
||||
(void)tdbTbcClose(pSkmDbC);
|
||||
tdbTbcClose(pSkmDbC);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -817,7 +817,7 @@ void metaCloseSmaCursor(SMSmaCursor *pSmaCur) {
|
|||
if (pSmaCur) {
|
||||
if (pSmaCur->pMeta) metaULock(pSmaCur->pMeta);
|
||||
if (pSmaCur->pCur) {
|
||||
(void)tdbTbcClose(pSmaCur->pCur);
|
||||
tdbTbcClose(pSmaCur->pCur);
|
||||
pSmaCur->pCur = NULL;
|
||||
|
||||
tdbFree(pSmaCur->pKey);
|
||||
|
@ -1117,7 +1117,7 @@ int32_t metaFilterCreateTime(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
|||
|
||||
END:
|
||||
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
||||
if (pCursor->pCur) (void)tdbTbcClose(pCursor->pCur);
|
||||
if (pCursor->pCur) tdbTbcClose(pCursor->pCur);
|
||||
taosMemoryFree(pCursor);
|
||||
return ret;
|
||||
}
|
||||
|
@ -1192,7 +1192,7 @@ int32_t metaFilterTableName(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
|||
|
||||
END:
|
||||
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
||||
if (pCursor->pCur) (void)tdbTbcClose(pCursor->pCur);
|
||||
if (pCursor->pCur) tdbTbcClose(pCursor->pCur);
|
||||
taosMemoryFree(buf);
|
||||
taosMemoryFree(pKey);
|
||||
|
||||
|
@ -1224,7 +1224,7 @@ int32_t metaFilterTtl(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
|||
|
||||
END:
|
||||
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
||||
if (pCursor->pCur) (void)tdbTbcClose(pCursor->pCur);
|
||||
if (pCursor->pCur) tdbTbcClose(pCursor->pCur);
|
||||
taosMemoryFree(buf);
|
||||
taosMemoryFree(pKey);
|
||||
|
||||
|
@ -1401,7 +1401,7 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
|||
|
||||
END:
|
||||
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
||||
if (pCursor->pCur) (void)tdbTbcClose(pCursor->pCur);
|
||||
if (pCursor->pCur) tdbTbcClose(pCursor->pCur);
|
||||
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
||||
tDecoderClear(&dc);
|
||||
tdbFree(pData);
|
||||
|
|
|
@ -59,7 +59,7 @@ _exit:
|
|||
|
||||
void metaSnapReaderClose(SMetaSnapReader** ppReader) {
|
||||
if (ppReader && *ppReader) {
|
||||
(void)tdbTbcClose((*ppReader)->pTbc);
|
||||
tdbTbcClose((*ppReader)->pTbc);
|
||||
taosMemoryFree(*ppReader);
|
||||
*ppReader = NULL;
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ static void destroySTableInfoForChildTable(void* data) {
|
|||
|
||||
static int32_t MoveToSnapShotVersion(SSnapContext* ctx) {
|
||||
int32_t code = 0;
|
||||
(void)tdbTbcClose((TBC*)ctx->pCur);
|
||||
tdbTbcClose((TBC*)ctx->pCur);
|
||||
code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
||||
if (code != 0) {
|
||||
return TAOS_GET_TERRNO(code);
|
||||
|
@ -239,7 +239,7 @@ static int32_t MoveToSnapShotVersion(SSnapContext* ctx) {
|
|||
}
|
||||
|
||||
static int32_t MoveToPosition(SSnapContext* ctx, int64_t ver, int64_t uid) {
|
||||
(void)tdbTbcClose((TBC*)ctx->pCur);
|
||||
tdbTbcClose((TBC*)ctx->pCur);
|
||||
int32_t code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
||||
if (code != 0) {
|
||||
return TAOS_GET_TERRNO(code);
|
||||
|
@ -254,7 +254,7 @@ static int32_t MoveToPosition(SSnapContext* ctx, int64_t ver, int64_t uid) {
|
|||
}
|
||||
|
||||
static int32_t MoveToFirst(SSnapContext* ctx) {
|
||||
(void)tdbTbcClose((TBC*)ctx->pCur);
|
||||
tdbTbcClose((TBC*)ctx->pCur);
|
||||
int32_t code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
||||
if (code != 0) {
|
||||
return TAOS_GET_TERRNO(code);
|
||||
|
@ -455,7 +455,7 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8
|
|||
}
|
||||
|
||||
void destroySnapContext(SSnapContext* ctx) {
|
||||
(void)tdbTbcClose((TBC*)ctx->pCur);
|
||||
tdbTbcClose((TBC*)ctx->pCur);
|
||||
taosArrayDestroy(ctx->idList);
|
||||
taosHashCleanup(ctx->idVersion);
|
||||
taosHashCleanup(ctx->suidInfo);
|
||||
|
|
|
@ -369,7 +369,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tb
|
|||
|
||||
rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = pReq->suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
||||
if (rc < 0) {
|
||||
(void)tdbTbcClose(pCtbIdxc);
|
||||
tdbTbcClose(pCtbIdxc);
|
||||
metaWLock(pMeta);
|
||||
goto _drop_super_table;
|
||||
}
|
||||
|
@ -386,12 +386,12 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tb
|
|||
|
||||
if (taosArrayPush(tbUidList, &(((SCtbIdxKey *)pKey)->uid)) == NULL) {
|
||||
tdbFree(pKey);
|
||||
(void)tdbTbcClose(pCtbIdxc);
|
||||
tdbTbcClose(pCtbIdxc);
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
|
||||
(void)tdbTbcClose(pCtbIdxc);
|
||||
tdbTbcClose(pCtbIdxc);
|
||||
|
||||
(void)tsdbCacheDropSubTables(pMeta->pVnode->pTsdb, tbUidList, pReq->suid);
|
||||
|
||||
|
@ -437,7 +437,7 @@ static int32_t metaGetSubtables(SMeta *pMeta, int64_t suid, SArray *uids) {
|
|||
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL));
|
||||
int rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
||||
if (rc < 0) {
|
||||
(void)tdbTbcClose(pCtbIdxc);
|
||||
tdbTbcClose(pCtbIdxc);
|
||||
metaWLock(pMeta);
|
||||
return 0;
|
||||
}
|
||||
|
@ -454,14 +454,14 @@ static int32_t metaGetSubtables(SMeta *pMeta, int64_t suid, SArray *uids) {
|
|||
|
||||
if (taosArrayPush(uids, &(((SCtbIdxKey *)pKey)->uid)) == NULL) {
|
||||
tdbFree(pKey);
|
||||
(void)tdbTbcClose(pCtbIdxc);
|
||||
tdbTbcClose(pCtbIdxc);
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
|
||||
tdbFree(pKey);
|
||||
|
||||
(void)tdbTbcClose(pCtbIdxc);
|
||||
tdbTbcClose(pCtbIdxc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -480,14 +480,14 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL));
|
||||
ret = tdbTbcMoveTo(pUidIdxc, &pReq->suid, sizeof(tb_uid_t), &c);
|
||||
if (ret < 0 || c) {
|
||||
(void)tdbTbcClose(pUidIdxc);
|
||||
tdbTbcClose(pUidIdxc);
|
||||
|
||||
return terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
||||
}
|
||||
|
||||
ret = tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData);
|
||||
if (ret < 0) {
|
||||
(void)tdbTbcClose(pUidIdxc);
|
||||
tdbTbcClose(pUidIdxc);
|
||||
|
||||
return terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
||||
}
|
||||
|
@ -497,8 +497,8 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL));
|
||||
ret = tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = pReq->suid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||
if (!(ret == 0 && c == 0)) {
|
||||
(void)tdbTbcClose(pUidIdxc);
|
||||
(void)tdbTbcClose(pTbDbc);
|
||||
tdbTbcClose(pUidIdxc);
|
||||
tdbTbcClose(pTbDbc);
|
||||
|
||||
metaError("meta/table: invalide ret: %" PRId32 " or c: %" PRId32 "alter stb failed.", ret, c);
|
||||
return terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
||||
|
@ -506,15 +506,15 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
|
||||
ret = tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
||||
if (ret < 0) {
|
||||
(void)tdbTbcClose(pUidIdxc);
|
||||
(void)tdbTbcClose(pTbDbc);
|
||||
tdbTbcClose(pUidIdxc);
|
||||
tdbTbcClose(pTbDbc);
|
||||
|
||||
return terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
||||
}
|
||||
|
||||
if ((oStbEntry.pBuf = taosMemoryMalloc(nData)) == NULL) {
|
||||
(void)tdbTbcClose(pTbDbc);
|
||||
(void)tdbTbcClose(pUidIdxc);
|
||||
tdbTbcClose(pTbDbc);
|
||||
tdbTbcClose(pUidIdxc);
|
||||
return terrno;
|
||||
}
|
||||
memcpy(oStbEntry.pBuf, pData, nData);
|
||||
|
@ -541,8 +541,8 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
if (uids == NULL) {
|
||||
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
||||
tDecoderClear(&dc);
|
||||
(void)tdbTbcClose(pTbDbc);
|
||||
(void)tdbTbcClose(pUidIdxc);
|
||||
tdbTbcClose(pTbDbc);
|
||||
tdbTbcClose(pUidIdxc);
|
||||
return terrno;
|
||||
}
|
||||
if (deltaCol == 1) {
|
||||
|
@ -603,8 +603,8 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
_exit:
|
||||
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
||||
tDecoderClear(&dc);
|
||||
(void)tdbTbcClose(pTbDbc);
|
||||
(void)tdbTbcClose(pUidIdxc);
|
||||
tdbTbcClose(pTbDbc);
|
||||
tdbTbcClose(pUidIdxc);
|
||||
return 0;
|
||||
}
|
||||
int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||
|
@ -695,7 +695,7 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
|
||||
code = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
||||
if (code < 0) {
|
||||
(void)tdbTbcClose(pCtbIdxc);
|
||||
tdbTbcClose(pCtbIdxc);
|
||||
goto _err;
|
||||
}
|
||||
for (;;) {
|
||||
|
@ -705,7 +705,7 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
if (code < 0) {
|
||||
tdbFree(pKey);
|
||||
tdbFree(pVal);
|
||||
(void)tdbTbcClose(pCtbIdxc);
|
||||
tdbTbcClose(pCtbIdxc);
|
||||
pCtbIdxc = NULL;
|
||||
break;
|
||||
}
|
||||
|
@ -740,7 +740,7 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
tdbFree(pVal);
|
||||
if (code < 0) {
|
||||
metaDestroyTagIdxKey(pTagIdxKey);
|
||||
(void)tdbTbcClose(pCtbIdxc);
|
||||
tdbTbcClose(pCtbIdxc);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -771,7 +771,7 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
tDecoderClear(&dc);
|
||||
tdbFree(pData);
|
||||
|
||||
(void)tdbTbcClose(pCtbIdxc);
|
||||
tdbTbcClose(pCtbIdxc);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
_err:
|
||||
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
||||
|
@ -844,7 +844,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
|
|||
|
||||
code = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
||||
if (code < 0) {
|
||||
(void)tdbTbcClose(pCtbIdxc);
|
||||
tdbTbcClose(pCtbIdxc);
|
||||
goto _err;
|
||||
}
|
||||
for (;;) {
|
||||
|
@ -855,7 +855,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
|
|||
if (code < 0) {
|
||||
tdbFree(pKey);
|
||||
tdbFree(pVal);
|
||||
(void)tdbTbcClose(pCtbIdxc);
|
||||
tdbTbcClose(pCtbIdxc);
|
||||
pCtbIdxc = NULL;
|
||||
break;
|
||||
}
|
||||
|
@ -891,7 +891,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
|
|||
tdbFree(pVal);
|
||||
if (code < 0) {
|
||||
metaDestroyTagIdxKey(pTagIdxKey);
|
||||
(void)tdbTbcClose(pCtbIdxc);
|
||||
tdbTbcClose(pCtbIdxc);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -919,7 +919,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
|
|||
tDeleteSColCmprWrapper(cmpr);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
||||
(void)tdbTbcClose(pCtbIdxc);
|
||||
tdbTbcClose(pCtbIdxc);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -945,7 +945,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
|
|||
tDecoderClear(&dc);
|
||||
tdbFree(pData);
|
||||
|
||||
(void)tdbTbcClose(pCtbIdxc);
|
||||
tdbTbcClose(pCtbIdxc);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
_err:
|
||||
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
||||
|
@ -1217,7 +1217,7 @@ static int32_t metaFilterTableByHash(SMeta *pMeta, SArray *uidList) {
|
|||
|
||||
code = tdbTbcMoveToFirst(pCur);
|
||||
if (code) {
|
||||
(void)tdbTbcClose(pCur);
|
||||
tdbTbcClose(pCur);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -1251,7 +1251,7 @@ static int32_t metaFilterTableByHash(SMeta *pMeta, SArray *uidList) {
|
|||
}
|
||||
tdbFree(pData);
|
||||
tdbFree(pKey);
|
||||
(void)tdbTbcClose(pCur);
|
||||
tdbTbcClose(pCur);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1537,7 +1537,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL));
|
||||
(void)tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||
if (c != 0) {
|
||||
(void)tdbTbcClose(pUidIdxc);
|
||||
tdbTbcClose(pUidIdxc);
|
||||
metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
@ -1551,8 +1551,8 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL));
|
||||
(void)tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||
if (c != 0) {
|
||||
(void)tdbTbcClose(pUidIdxc);
|
||||
(void)tdbTbcClose(pTbDbc);
|
||||
tdbTbcClose(pUidIdxc);
|
||||
tdbTbcClose(pTbDbc);
|
||||
metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
@ -1570,8 +1570,8 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
tDecoderInit(&dc, entry.pBuf, nData);
|
||||
ret = metaDecodeEntry(&dc, &entry);
|
||||
if (ret != 0) {
|
||||
(void)tdbTbcClose(pUidIdxc);
|
||||
(void)tdbTbcClose(pTbDbc);
|
||||
tdbTbcClose(pUidIdxc);
|
||||
tdbTbcClose(pTbDbc);
|
||||
tDecoderClear(&dc);
|
||||
metaError("meta/table: invalide ret: %" PRId32 " alt tb column failed.", ret);
|
||||
return ret;
|
||||
|
@ -1770,16 +1770,16 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
if (pNewSchema) taosMemoryFree(pNewSchema);
|
||||
if (freeColCmpr) taosMemoryFree(entry.colCmpr.pColCmpr);
|
||||
|
||||
(void)tdbTbcClose(pTbDbc);
|
||||
(void)tdbTbcClose(pUidIdxc);
|
||||
tdbTbcClose(pTbDbc);
|
||||
tdbTbcClose(pUidIdxc);
|
||||
tDecoderClear(&dc);
|
||||
|
||||
return 0;
|
||||
|
||||
_err:
|
||||
if (entry.pBuf) taosMemoryFree(entry.pBuf);
|
||||
(void)tdbTbcClose(pTbDbc);
|
||||
(void)tdbTbcClose(pUidIdxc);
|
||||
tdbTbcClose(pTbDbc);
|
||||
tdbTbcClose(pUidIdxc);
|
||||
tDecoderClear(&dc);
|
||||
|
||||
return terrno != 0 ? terrno : TSDB_CODE_FAILED;
|
||||
|
@ -1817,7 +1817,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
|||
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL));
|
||||
(void)tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||
if (c != 0) {
|
||||
(void)tdbTbcClose(pUidIdxc);
|
||||
tdbTbcClose(pUidIdxc);
|
||||
metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c);
|
||||
return terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
||||
}
|
||||
|
@ -1834,8 +1834,8 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
|||
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL));
|
||||
(void)tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||
if (c != 0) {
|
||||
(void)tdbTbcClose(pUidIdxc);
|
||||
(void)tdbTbcClose(pTbDbc);
|
||||
tdbTbcClose(pUidIdxc);
|
||||
tdbTbcClose(pTbDbc);
|
||||
metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c);
|
||||
return terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
||||
}
|
||||
|
@ -1968,8 +1968,8 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
|||
taosMemoryFree((void *)ctbEntry.ctbEntry.pTags);
|
||||
if (ctbEntry.pBuf) taosMemoryFree(ctbEntry.pBuf);
|
||||
if (stbEntry.pBuf) tdbFree(stbEntry.pBuf);
|
||||
(void)tdbTbcClose(pTbDbc);
|
||||
(void)tdbTbcClose(pUidIdxc);
|
||||
tdbTbcClose(pTbDbc);
|
||||
tdbTbcClose(pUidIdxc);
|
||||
return 0;
|
||||
|
||||
_err:
|
||||
|
@ -1977,8 +1977,8 @@ _err:
|
|||
tDecoderClear(&dc2);
|
||||
if (ctbEntry.pBuf) taosMemoryFree(ctbEntry.pBuf);
|
||||
if (stbEntry.pBuf) tdbFree(stbEntry.pBuf);
|
||||
(void)tdbTbcClose(pTbDbc);
|
||||
(void)tdbTbcClose(pUidIdxc);
|
||||
tdbTbcClose(pTbDbc);
|
||||
tdbTbcClose(pUidIdxc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -2009,7 +2009,7 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
|||
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL));
|
||||
(void)tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||
if (c != 0) {
|
||||
(void)tdbTbcClose(pUidIdxc);
|
||||
tdbTbcClose(pUidIdxc);
|
||||
metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
@ -2023,8 +2023,8 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
|||
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL));
|
||||
(void)tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||
if (c != 0) {
|
||||
(void)tdbTbcClose(pUidIdxc);
|
||||
(void)tdbTbcClose(pTbDbc);
|
||||
tdbTbcClose(pUidIdxc);
|
||||
tdbTbcClose(pTbDbc);
|
||||
metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
@ -2043,8 +2043,8 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
|||
ret = metaDecodeEntry(&dc, &entry);
|
||||
if (ret != 0) {
|
||||
tDecoderClear(&dc);
|
||||
(void)tdbTbcClose(pUidIdxc);
|
||||
(void)tdbTbcClose(pTbDbc);
|
||||
tdbTbcClose(pUidIdxc);
|
||||
tdbTbcClose(pTbDbc);
|
||||
metaError("meta/table: invalide ret: %" PRId32 " alt tb options failed.", ret);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
@ -2081,8 +2081,8 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
|||
|
||||
metaULock(pMeta);
|
||||
|
||||
(void)tdbTbcClose(pTbDbc);
|
||||
(void)tdbTbcClose(pUidIdxc);
|
||||
tdbTbcClose(pTbDbc);
|
||||
tdbTbcClose(pUidIdxc);
|
||||
tDecoderClear(&dc);
|
||||
if (entry.pBuf) taosMemoryFree(entry.pBuf);
|
||||
return 0;
|
||||
|
@ -2162,7 +2162,7 @@ static int metaAddTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTb
|
|||
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL));
|
||||
int rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
||||
if (rc < 0) {
|
||||
(void)tdbTbcClose(pCtbIdxc);
|
||||
tdbTbcClose(pCtbIdxc);
|
||||
goto _err;
|
||||
}
|
||||
for (;;) {
|
||||
|
@ -2199,14 +2199,14 @@ static int metaAddTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTb
|
|||
tdbFree(pKey);
|
||||
tdbFree(pVal);
|
||||
metaDestroyTagIdxKey(pTagIdxKey);
|
||||
(void)tdbTbcClose(pCtbIdxc);
|
||||
tdbTbcClose(pCtbIdxc);
|
||||
goto _err;
|
||||
}
|
||||
(void)tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, pMeta->txn);
|
||||
metaDestroyTagIdxKey(pTagIdxKey);
|
||||
pTagIdxKey = NULL;
|
||||
}
|
||||
(void)tdbTbcClose(pCtbIdxc);
|
||||
tdbTbcClose(pCtbIdxc);
|
||||
return 0;
|
||||
|
||||
_err:
|
||||
|
@ -2320,7 +2320,7 @@ static int metaDropTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterT
|
|||
goto _err;
|
||||
}
|
||||
}
|
||||
(void)tdbTbcClose(pTagIdxc);
|
||||
tdbTbcClose(pTagIdxc);
|
||||
|
||||
metaWLock(pMeta);
|
||||
for (int i = 0; i < taosArrayGetSize(tagIdxList); i++) {
|
||||
|
|
|
@ -389,10 +389,7 @@ static int32_t tqMetaTransformInfo(TDB* pMetaDB, TTB* pOld, TTB* pNew) {
|
|||
END:
|
||||
tdbFree(pKey);
|
||||
tdbFree(pVal);
|
||||
int32_t ret = tdbTbcClose(pCur);
|
||||
if (ret != 0) {
|
||||
tqError("failed to close tbc, ret:%d", ret);
|
||||
}
|
||||
tdbTbcClose(pCur);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -464,10 +461,7 @@ static int32_t tqMetaRestoreCheckInfo(STQ* pTq) {
|
|||
END:
|
||||
tdbFree(pKey);
|
||||
tdbFree(pVal);
|
||||
int32_t ret = tdbTbcClose(pCur);
|
||||
if (ret != 0) {
|
||||
tqError("failed to close tbc, ret:%d", ret);
|
||||
}
|
||||
tdbTbcClose(pCur);
|
||||
tDeleteSTqCheckInfo(&info);
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -77,10 +77,7 @@ _err:
|
|||
}
|
||||
|
||||
void tqSnapReaderClose(STqSnapReader** ppReader) {
|
||||
int32_t ret = tdbTbcClose((*ppReader)->pCur);
|
||||
if (ret != 0){
|
||||
tqError("vgId:%d, vnode snapshot tq reader close failed since %s", TD_VID((*ppReader)->pTq->pVnode), tstrerror(ret));
|
||||
}
|
||||
tdbTbcClose((*ppReader)->pCur);
|
||||
taosMemoryFree(*ppReader);
|
||||
*ppReader = NULL;
|
||||
}
|
||||
|
|
|
@ -97,12 +97,8 @@ int32_t streamTaskSnapReaderClose(SStreamTaskReader* pReader) {
|
|||
int32_t vgId = TD_VID(pReader->pTq->pVnode);
|
||||
|
||||
taosArrayDestroy(pReader->tdbTbList);
|
||||
code = tdbTbcClose(pReader->pCur);
|
||||
if (code) {
|
||||
tqError("vgId:%d failed to close stream meta reader, code:%s", vgId, tstrerror(code));
|
||||
} else {
|
||||
tqInfo("vgId:%d, vnode stream-task snapshot reader closed", vgId);
|
||||
}
|
||||
tdbTbcClose(pReader->pCur);
|
||||
tqInfo("vgId:%d, vnode stream-task snapshot reader closed", vgId);
|
||||
|
||||
taosMemoryFree(pReader);
|
||||
return code;
|
||||
|
@ -146,7 +142,7 @@ NextTbl:
|
|||
}
|
||||
if (except == 1) {
|
||||
if (pReader->pos + 1 < taosArrayGetSize(pReader->tdbTbList)) {
|
||||
(void)tdbTbcClose(pReader->pCur);
|
||||
tdbTbcClose(pReader->pCur);
|
||||
|
||||
pReader->pos += 1;
|
||||
pPair = taosArrayGet(pReader->tdbTbList, pReader->pos);
|
||||
|
|
|
@ -433,7 +433,7 @@ static int32_t tsdbCacheQueryReseek(void* pQHandle) {
|
|||
}
|
||||
|
||||
int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32_t* slotIds, const int32_t* dstSlotIds,
|
||||
SArray* pTableUidList) {
|
||||
SArray* pTableUidList, bool* pGotAll) {
|
||||
if (pReader == NULL || pResBlock == NULL) {
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
@ -642,7 +642,8 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
|||
|
||||
taosArrayDestroyEx(pLastCols, tsdbCacheFreeSLastColItem);
|
||||
} else if (HASTYPE(pr->type, CACHESCAN_RETRIEVE_TYPE_ALL)) {
|
||||
for (int32_t i = pr->tableIndex; i < pr->numOfTables; ++i) {
|
||||
int32_t i = pr->tableIndex;
|
||||
for (; i < pr->numOfTables; ++i) {
|
||||
tb_uid_t uid = pTableList[i].uid;
|
||||
|
||||
if ((code = tsdbCacheGetBatch(pr->pTsdb, uid, pRow, pr, ltype)) != 0) {
|
||||
|
@ -673,9 +674,13 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
|||
|
||||
++pr->tableIndex;
|
||||
if (pResBlock->info.rows >= pResBlock->info.capacity) {
|
||||
goto _end;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pGotAll && i == pr->numOfTables) {
|
||||
*pGotAll = true;
|
||||
}
|
||||
} else {
|
||||
code = TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ typedef struct SCacheRowsScanInfo {
|
|||
SArray* pFuncTypeList;
|
||||
int32_t numOfPks;
|
||||
SColumnInfo pkCol;
|
||||
bool gotAll;
|
||||
} SCacheRowsScanInfo;
|
||||
|
||||
static int32_t doScanCacheNext(SOperatorInfo* pOperator, SSDataBlock** ppRes);
|
||||
|
@ -292,12 +293,12 @@ static int32_t doScanCacheNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) {
|
|||
T_LONG_JMP(pTaskInfo->env, pTaskInfo->code);
|
||||
}
|
||||
|
||||
if (pInfo->indexOfBufferedRes >= pBufRes->info.rows) {
|
||||
if (pInfo->indexOfBufferedRes >= pBufRes->info.rows && !pInfo->gotAll) {
|
||||
blockDataCleanup(pBufRes);
|
||||
taosArrayClear(pInfo->pUidList);
|
||||
|
||||
code =
|
||||
pReaderFn->retrieveRows(pInfo->pLastrowReader, pBufRes, pInfo->pSlotIds, pInfo->pDstSlotIds, pInfo->pUidList);
|
||||
code = pReaderFn->retrieveRows(pInfo->pLastrowReader, pBufRes, pInfo->pSlotIds, pInfo->pDstSlotIds,
|
||||
pInfo->pUidList, &pInfo->gotAll);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
// check for tag values
|
||||
|
@ -394,7 +395,7 @@ static int32_t doScanCacheNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) {
|
|||
taosArrayClear(pInfo->pUidList);
|
||||
|
||||
code = pReaderFn->retrieveRows(pInfo->pLastrowReader, pInfo->pRes, pInfo->pSlotIds, pInfo->pDstSlotIds,
|
||||
pInfo->pUidList);
|
||||
pInfo->pUidList, NULL);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
||||
pInfo->currentGroupIndex += 1;
|
||||
|
|
|
@ -697,7 +697,7 @@ static void freeStbJoinTableList(SStbJoinTableList* pList) {
|
|||
|
||||
static int32_t appendStbJoinTableList(SStbJoinPrevJoinCtx* pCtx, int64_t rows, int32_t* pLeftVg, int64_t* pLeftUid, int32_t* pRightVg, int64_t* pRightUid) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SStbJoinTableList* pNew = taosMemoryMalloc(sizeof(SStbJoinTableList));
|
||||
SStbJoinTableList* pNew = taosMemoryCalloc(1, sizeof(SStbJoinTableList));
|
||||
if (NULL == pNew) {
|
||||
return terrno;
|
||||
}
|
||||
|
|
|
@ -1037,16 +1037,13 @@ static int32_t getCacheBlkFromDownstreamOperator(struct SOperatorInfo* pOperator
|
|||
SGroupCacheOperatorInfo* pGCache = pOperator->info;
|
||||
|
||||
while (continueFetch && TSDB_CODE_SUCCESS == code) {
|
||||
int32_t code = getBlkFromDownstreamOperator(pOperator, pSession->downstreamIdx, ppRes);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
QRY_ERR_RET(getBlkFromDownstreamOperator(pOperator, pSession->downstreamIdx, ppRes));
|
||||
|
||||
if (NULL == *ppRes) {
|
||||
code = handleDownstreamFetchDone(pOperator, pSession);
|
||||
QRY_ERR_RET(handleDownstreamFetchDone(pOperator, pSession));
|
||||
break;
|
||||
} else {
|
||||
code = handleGroupCacheRetrievedBlk(pOperator, *ppRes, pSession, &continueFetch);
|
||||
QRY_ERR_RET(handleGroupCacheRetrievedBlk(pOperator, *ppRes, pSession, &continueFetch));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1129,6 +1126,11 @@ static int32_t getBlkFromSessionCacheImpl(struct SOperatorInfo* pOperator, int64
|
|||
|
||||
|
||||
static int32_t groupCacheSessionWait(struct SOperatorInfo* pOperator, SGcDownstreamCtx* pCtx, int64_t sessionId, SGcSessionCtx* pSession, SSDataBlock** ppRes) {
|
||||
// FOR NOW, IT'S ERROR TO REACH HERE
|
||||
#if 1
|
||||
qError("should not enter session wait");
|
||||
return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
|
||||
#else
|
||||
SGroupCacheOperatorInfo* pGCache = pOperator->info;
|
||||
SGroupCacheData* pGroup = pSession->pGroupData;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
@ -1181,6 +1183,7 @@ _return:
|
|||
}
|
||||
|
||||
return code;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -1206,6 +1209,10 @@ static int32_t getBlkFromSessionCache(struct SOperatorInfo* pOperator, int64_t s
|
|||
|
||||
code = getCacheBlkFromDownstreamOperator(pOperator, pCtx, sessionId, pSession, ppRes);
|
||||
goto _return;
|
||||
} else {
|
||||
// FOR NOW, SHOULD NOT REACH HERE
|
||||
qError("Invalid fetchSessionId:%" PRId64 ", currentSessionId:%" PRId64, pCtx->fetchSessionId, sessionId);
|
||||
return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
if (locked) {
|
||||
|
@ -1292,6 +1299,9 @@ static int32_t initGroupCacheSession(struct SOperatorInfo* pOperator, SOperatorP
|
|||
qError("fail to get session %" PRId64 " from pSessions", pGcParam->sessionId);
|
||||
QRY_ERR_RET(TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
qDebug("session:%" PRId64 " initialized, downstreamIdx:%d, vgId:%d, tbUid:%" PRId64 ", needCache:%d",
|
||||
pGcParam->sessionId, pGcParam->downstreamIdx, pGcParam->vgId, pGcParam->tbUid, pGcParam->needCache);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -1323,7 +1333,7 @@ static int32_t getBlkFromGroupCache(struct SOperatorInfo* pOperator, SSDataBlock
|
|||
}
|
||||
}
|
||||
|
||||
code = getBlkFromSessionCache(pOperator, pGcParam->sessionId, pSession, ppRes);
|
||||
QRY_ERR_RET(getBlkFromSessionCache(pOperator, pGcParam->sessionId, pSession, ppRes));
|
||||
if (NULL == *ppRes) {
|
||||
qDebug("session %" PRId64 " in downstream %d total got %" PRId64 " rows", pGcParam->sessionId, pCtx->id, pSession->resRows);
|
||||
code = taosHashRemove(pCtx->pSessions, &pGcParam->sessionId, sizeof(pGcParam->sessionId));
|
||||
|
|
|
@ -4828,6 +4828,9 @@ int32_t histogramFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResul
|
|||
pInfo->normalized = 0;
|
||||
|
||||
char* binTypeStr = strndup(varDataVal(pCtx->param[1].param.pz), varDataLen(pCtx->param[1].param.pz));
|
||||
if (binTypeStr == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
int8_t binType = getHistogramBinType(binTypeStr);
|
||||
taosMemoryFree(binTypeStr);
|
||||
|
||||
|
@ -4835,6 +4838,9 @@ int32_t histogramFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResul
|
|||
return TSDB_CODE_FUNC_FUNTION_PARA_VALUE;
|
||||
}
|
||||
char* binDesc = strndup(varDataVal(pCtx->param[2].param.pz), varDataLen(pCtx->param[2].param.pz));
|
||||
if (binDesc == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
int64_t normalized = pCtx->param[3].param.i;
|
||||
if (normalized != 0 && normalized != 1) {
|
||||
taosMemoryFree(binDesc);
|
||||
|
|
|
@ -43,6 +43,10 @@ int32_t tHistogramCreate(int32_t numOfEntries, SHistogramInfo** pHisto) {
|
|||
#if !defined(USE_ARRAYLIST)
|
||||
pHisto->pList = SSkipListCreate(MAX_SKIP_LIST_LEVEL, TSDB_DATA_TYPE_DOUBLE, sizeof(double));
|
||||
SInsertSupporter* pss = taosMemoryMalloc(sizeof(SInsertSupporter));
|
||||
if (NULL == pss) {
|
||||
taosMemoryFree(*pHisto);
|
||||
return terrno;
|
||||
}
|
||||
pss->numOfEntries = pHisto->maxEntries;
|
||||
pss->pSkipList = pHisto->pList;
|
||||
|
||||
|
@ -119,6 +123,9 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
|
|||
#else
|
||||
tSkipListKey key = tSkipListCreateKey(TSDB_DATA_TYPE_DOUBLE, &val, tDataTypes[TSDB_DATA_TYPE_DOUBLE].nSize);
|
||||
SHistBin* entry = taosMemoryCalloc(1, sizeof(SHistBin));
|
||||
if (entry == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
entry->val = val;
|
||||
|
||||
tSkipListNode* pResNode = SSkipListPut((*pHisto)->pList, entry, &key, 0);
|
||||
|
|
|
@ -4353,10 +4353,16 @@ int32_t histogramScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
|
|||
int32_t totalCount = 0;
|
||||
|
||||
char *binTypeStr = strndup(varDataVal(pInput[1].columnData->pData), varDataLen(pInput[1].columnData->pData));
|
||||
if (NULL == binTypeStr) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
int8_t binType = getHistogramBinType(binTypeStr);
|
||||
taosMemoryFree(binTypeStr);
|
||||
|
||||
char *binDesc = strndup(varDataVal(pInput[2].columnData->pData), varDataLen(pInput[2].columnData->pData));
|
||||
if (NULL == binDesc) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
int64_t normalized = *(int64_t *)(pInput[3].columnData->pData);
|
||||
|
||||
int32_t type = GET_PARAM_TYPE(pInput);
|
||||
|
|
|
@ -596,6 +596,11 @@ int32_t ncharTobinary(void *buf, void **out) { // todo need to remove , if tobi
|
|||
int32_t inputLen = varDataTLen(buf);
|
||||
|
||||
*out = taosMemoryCalloc(1, inputLen);
|
||||
if (NULL == *out) {
|
||||
sclError("charset:%s to %s. val:%s convert ncharTobinary failed, since memory alloc failed.",
|
||||
DEFAULT_UNICODE_ENCODEC, tsCharset, (char *)varDataVal(buf));
|
||||
SCL_ERR_RET(terrno);
|
||||
}
|
||||
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(buf), varDataLen(buf), varDataVal(*out));
|
||||
if (len < 0) {
|
||||
sclError("charset:%s to %s. val:%s convert ncharTobinary failed.", DEFAULT_UNICODE_ENCODEC, tsCharset,
|
||||
|
|
|
@ -191,11 +191,7 @@ int32_t streamMetaCheckBackendCompatible(SStreamMeta* pMeta) {
|
|||
if (code) {
|
||||
stError("vgId:%d failed to open stream meta file cursor, not perform compatible check, code:%s", pMeta->vgId,
|
||||
tstrerror(code));
|
||||
code = tdbTbcClose(pCur);
|
||||
if (code) {
|
||||
stError("vgId:%d failed to close meta file cursor, code:%s", pMeta->vgId, tstrerror(code));
|
||||
}
|
||||
|
||||
tdbTbcClose(pCur);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -223,10 +219,7 @@ int32_t streamMetaCheckBackendCompatible(SStreamMeta* pMeta) {
|
|||
|
||||
tdbFree(pKey);
|
||||
tdbFree(pVal);
|
||||
code = tdbTbcClose(pCur);
|
||||
if (code != 0) {
|
||||
stError("vgId:%d failed to close meta file cursor, code:%s", pMeta->vgId, tstrerror(code));
|
||||
}
|
||||
tdbTbcClose(pCur);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -977,10 +970,7 @@ int64_t streamMetaGetLatestCheckpointId(SStreamMeta* pMeta) {
|
|||
code = tdbTbcMoveToFirst(pCur);
|
||||
if (code) {
|
||||
stError("failed to move stream meta file cursor, the latest checkpointId is 0, vgId:%d", pMeta->vgId);
|
||||
int32_t ret = tdbTbcClose(pCur);
|
||||
if (ret != 0) {
|
||||
stError("vgId:%d failed to close meta file cursor, code:%s", pMeta->vgId, tstrerror(ret));
|
||||
}
|
||||
tdbTbcClose(pCur);
|
||||
return checkpointId;
|
||||
}
|
||||
|
||||
|
@ -1003,11 +993,7 @@ int64_t streamMetaGetLatestCheckpointId(SStreamMeta* pMeta) {
|
|||
tdbFree(pKey);
|
||||
tdbFree(pVal);
|
||||
|
||||
int32_t ret = tdbTbcClose(pCur);
|
||||
if (ret != 0) {
|
||||
stError("vgId:%d failed to close meta file cursor, code:%s", pMeta->vgId, tstrerror(ret));
|
||||
}
|
||||
|
||||
tdbTbcClose(pCur);
|
||||
return checkpointId;
|
||||
}
|
||||
|
||||
|
@ -1047,10 +1033,7 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) {
|
|||
if (code) {
|
||||
stError("vgId:%d failed to open stream meta cursor, code:%s, not load any stream tasks", vgId, tstrerror(terrno));
|
||||
taosArrayDestroy(pRecycleList);
|
||||
int32_t ret = tdbTbcClose(pCur);
|
||||
if (ret != 0) {
|
||||
stError("vgId:%d failed to close meta file cursor, code:%s", pMeta->vgId, tstrerror(ret));
|
||||
}
|
||||
tdbTbcClose(pCur);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1137,9 +1120,7 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) {
|
|||
tdbFree(pKey);
|
||||
tdbFree(pVal);
|
||||
|
||||
if (tdbTbcClose(pCur) < 0) {
|
||||
stError("vgId:%d failed to close meta-file cursor, code:%s, continue", vgId, tstrerror(terrno));
|
||||
}
|
||||
tdbTbcClose(pCur);
|
||||
|
||||
if (taosArrayGetSize(pRecycleList) > 0) {
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pRecycleList); ++i) {
|
||||
|
|
|
@ -60,7 +60,7 @@ int32_t tdbTbTraversal(TTB *pTb, void *data,
|
|||
|
||||
// TBC
|
||||
int32_t tdbTbcOpen(TTB *pTb, TBC **ppTbc, TXN *pTxn);
|
||||
int32_t tdbTbcClose(TBC *pTbc);
|
||||
void tdbTbcClose(TBC *pTbc);
|
||||
int32_t tdbTbcIsValid(TBC *pTbc);
|
||||
int32_t tdbTbcMoveTo(TBC *pTbc, const void *pKey, int kLen, int *c);
|
||||
int32_t tdbTbcMoveToFirst(TBC *pTbc);
|
||||
|
|
|
@ -172,12 +172,11 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPg
|
|||
return 0;
|
||||
}
|
||||
|
||||
int tdbBtreeClose(SBTree *pBt) {
|
||||
void tdbBtreeClose(SBTree *pBt) {
|
||||
if (pBt) {
|
||||
tdbFree(pBt->pBuf);
|
||||
tdbOsFree(pBt);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, int vLen, TXN *pTxn) {
|
||||
|
@ -201,7 +200,7 @@ int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, in
|
|||
// move to the position to insert
|
||||
ret = tdbBtcMoveTo(&btc, pKey, kLen, &c);
|
||||
if (ret < 0) {
|
||||
(void)tdbBtcClose(&btc);
|
||||
tdbBtcClose(&btc);
|
||||
tdbError("tdb/btree-insert: btc move to failed with ret: %d.", ret);
|
||||
return ret;
|
||||
}
|
||||
|
@ -213,7 +212,7 @@ int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, in
|
|||
btc.idx++;
|
||||
} else if (c == 0) {
|
||||
// dup key not allowed with insert
|
||||
(void)tdbBtcClose(&btc);
|
||||
tdbBtcClose(&btc);
|
||||
tdbError("tdb/btree-insert: dup key. pKey: %p, kLen: %d, btc: %p, pTxn: %p", pKey, kLen, &btc, pTxn);
|
||||
return TSDB_CODE_DUP_KEY;
|
||||
}
|
||||
|
@ -221,12 +220,12 @@ int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, in
|
|||
|
||||
ret = tdbBtcUpsert(&btc, pKey, kLen, pVal, vLen, 1);
|
||||
if (ret < 0) {
|
||||
(void)tdbBtcClose(&btc);
|
||||
tdbBtcClose(&btc);
|
||||
tdbError("tdb/btree-insert: btc upsert failed with ret: %d.", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
(void)tdbBtcClose(&btc);
|
||||
tdbBtcClose(&btc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -250,20 +249,20 @@ int tdbBtreeDelete(SBTree *pBt, const void *pKey, int kLen, TXN *pTxn) {
|
|||
// move the cursor
|
||||
ret = tdbBtcMoveTo(&btc, pKey, kLen, &c);
|
||||
if (ret < 0) {
|
||||
(void)tdbBtcClose(&btc);
|
||||
tdbBtcClose(&btc);
|
||||
tdbError("tdb/btree-delete: btc move to failed with ret: %d.", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (btc.idx < 0 || c != 0) {
|
||||
(void)tdbBtcClose(&btc);
|
||||
tdbBtcClose(&btc);
|
||||
return TSDB_CODE_NOT_FOUND;
|
||||
}
|
||||
|
||||
// delete the key
|
||||
ret = tdbBtcDelete(&btc);
|
||||
if (ret < 0) {
|
||||
(void)tdbBtcClose(&btc);
|
||||
tdbBtcClose(&btc);
|
||||
return ret;
|
||||
}
|
||||
/*
|
||||
|
@ -278,7 +277,7 @@ int tdbBtreeDelete(SBTree *pBt, const void *pKey, int kLen, TXN *pTxn) {
|
|||
btc.coder.ofps = NULL;
|
||||
}
|
||||
*/
|
||||
(void)tdbBtcClose(&btc);
|
||||
tdbBtcClose(&btc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -351,20 +350,20 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL
|
|||
|
||||
ret = tdbBtcMoveTo(&btc, pKey, kLen, &cret);
|
||||
if (ret < 0) {
|
||||
(void)tdbBtcClose(&btc);
|
||||
tdbBtcClose(&btc);
|
||||
tdbError("tdb/btree-pget: btc move to failed with ret: %d.", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (btc.idx < 0 || cret) {
|
||||
(void)tdbBtcClose(&btc);
|
||||
tdbBtcClose(&btc);
|
||||
return TSDB_CODE_NOT_FOUND;
|
||||
}
|
||||
|
||||
pCell = tdbPageGetCell(btc.pPage, btc.idx);
|
||||
ret = tdbBtreeDecodeCell(btc.pPage, pCell, &cd, btc.pTxn, pBt);
|
||||
if (ret < 0) {
|
||||
(void)tdbBtcClose(&btc);
|
||||
tdbBtcClose(&btc);
|
||||
tdbError("tdb/btree-pget: decode cell failed with ret: %d.", ret);
|
||||
return ret;
|
||||
}
|
||||
|
@ -372,7 +371,7 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL
|
|||
if (ppKey) {
|
||||
pTKey = tdbRealloc(*ppKey, cd.kLen);
|
||||
if (pTKey == NULL) {
|
||||
(void)tdbBtcClose(&btc);
|
||||
tdbBtcClose(&btc);
|
||||
tdbError("tdb/btree-pget: realloc pTKey failed.");
|
||||
return terrno;
|
||||
}
|
||||
|
@ -384,7 +383,7 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL
|
|||
if (ppVal) {
|
||||
pTVal = tdbRealloc(*ppVal, cd.vLen);
|
||||
if (pTVal == NULL) {
|
||||
(void)tdbBtcClose(&btc);
|
||||
tdbBtcClose(&btc);
|
||||
tdbError("tdb/btree-pget: realloc pTVal failed.");
|
||||
return terrno;
|
||||
}
|
||||
|
@ -405,7 +404,7 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL
|
|||
|
||||
tdbTrace("tdb pget end, btc decoder: %p/0x%x, local decoder:%p", &btc.coder, btc.coder.freeKV, &cd);
|
||||
|
||||
(void)tdbBtcClose(&btc);
|
||||
tdbBtcClose(&btc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -606,7 +605,11 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
|||
if (i < nOlds - 1) {
|
||||
((SPgno *)pDivCell[i])[0] = ((SIntHdr *)pOlds[i]->pData)->pgno;
|
||||
((SIntHdr *)pOlds[i]->pData)->pgno = 0;
|
||||
(void)tdbPageInsertCell(pOlds[i], TDB_PAGE_TOTAL_CELLS(pOlds[i]), pDivCell[i], szDivCell[i], 1);
|
||||
ret = tdbPageInsertCell(pOlds[i], TDB_PAGE_TOTAL_CELLS(pOlds[i]), pDivCell[i], szDivCell[i], 1);
|
||||
if (ret < 0) {
|
||||
tdbError("tdb/btree-balance: insert cell failed with ret: %d.", ret);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
}
|
||||
}
|
||||
rPgno = ((SIntHdr *)pOlds[nOlds - 1]->pData)->pgno;
|
||||
|
@ -793,15 +796,31 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
|||
iarg.pBt = pBt;
|
||||
iarg.flags = TDB_BTREE_PAGE_GET_FLAGS(pOlds[0]);
|
||||
for (int i = 0; i < nOlds; i++) {
|
||||
(void)tdbPageCreate(pOlds[0]->pageSize, &pOldsCopy[i], tdbDefaultMalloc, NULL);
|
||||
(void)tdbBtreeInitPage(pOldsCopy[i], &iarg, 0);
|
||||
(void)tdbPageCopy(pOlds[i], pOldsCopy[i], 0);
|
||||
ret = tdbPageCreate(pOlds[0]->pageSize, &pOldsCopy[i], tdbDefaultMalloc, NULL);
|
||||
if (ret < 0) {
|
||||
tdbError("tdb/btree-balance: create page failed with ret: %d.", ret);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
ret = tdbBtreeInitPage(pOldsCopy[i], &iarg, 0);
|
||||
if (ret < 0) {
|
||||
tdbError("tdb/btree-balance: init page failed with ret: %d.", ret);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
ret = tdbPageCopy(pOlds[i], pOldsCopy[i], 0);
|
||||
if (ret < 0) {
|
||||
tdbError("tdb/btree-balance: copy page failed with ret: %d.", ret);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
pOlds[i]->nOverflow = 0;
|
||||
}
|
||||
|
||||
iNew = 0;
|
||||
nNewCells = 0;
|
||||
(void)tdbBtreeInitPage(pNews[iNew], &iarg, 0);
|
||||
ret = tdbBtreeInitPage(pNews[iNew], &iarg, 0);
|
||||
if (ret < 0) {
|
||||
tdbError("tdb/btree-balance: init page failed with ret: %d.", ret);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
for (int iOld = 0; iOld < nOlds; iOld++) {
|
||||
SPage *pPage;
|
||||
|
@ -820,7 +839,11 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
|||
}
|
||||
|
||||
if (nNewCells < infoNews[iNew].cnt) {
|
||||
(void)tdbPageInsertCell(pNews[iNew], nNewCells, pCell, szCell, 0);
|
||||
ret = tdbPageInsertCell(pNews[iNew], nNewCells, pCell, szCell, 0);
|
||||
if (ret < 0) {
|
||||
tdbError("tdb/btree-balance: insert cell failed with ret: %d.", ret);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
nNewCells++;
|
||||
|
||||
// insert parent page
|
||||
|
@ -842,7 +865,11 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
|||
pgno = TDB_PAGE_PGNO(pNews[iNew]);
|
||||
(void)tdbBtreeEncodeCell(pParent, cd.pKey, cd.kLen, (void *)&pgno, sizeof(SPgno), pNewCell, &szNewCell,
|
||||
pTxn, pBt);
|
||||
(void)tdbPageInsertCell(pParent, sIdx++, pNewCell, szNewCell, 0);
|
||||
ret = tdbPageInsertCell(pParent, sIdx++, pNewCell, szNewCell, 0);
|
||||
if (ret) {
|
||||
tdbError("tdb/btree-balance: insert cell failed with ret: %d.", ret);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
tdbOsFree(pNewCell);
|
||||
|
||||
if (TDB_CELLDECODER_FREE_VAL(&cd)) {
|
||||
|
@ -855,7 +882,11 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
|||
iNew++;
|
||||
nNewCells = 0;
|
||||
if (iNew < nNews) {
|
||||
(void)tdbBtreeInitPage(pNews[iNew], &iarg, 0);
|
||||
ret = tdbBtreeInitPage(pNews[iNew], &iarg, 0);
|
||||
if (ret < 0) {
|
||||
tdbError("tdb/btree-balance: init page failed with ret: %d.", ret);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -874,13 +905,21 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
|||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
((SPgno *)pCell)[0] = TDB_PAGE_PGNO(pNews[iNew]);
|
||||
(void)tdbPageInsertCell(pParent, sIdx++, pCell, szCell, 0);
|
||||
ret = tdbPageInsertCell(pParent, sIdx++, pCell, szCell, 0);
|
||||
if (ret) {
|
||||
tdbError("tdb/btree-balance: insert cell failed with ret: %d.", ret);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
// move to next new page
|
||||
iNew++;
|
||||
nNewCells = 0;
|
||||
if (iNew < nNews) {
|
||||
(void)tdbBtreeInitPage(pNews[iNew], &iarg, 0);
|
||||
ret = tdbBtreeInitPage(pNews[iNew], &iarg, 0);
|
||||
if (ret < 0) {
|
||||
tdbError("tdb/btree-balance: init page failed with ret: %d.", ret);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -897,26 +936,39 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
|||
pIntHdr->pgno = TDB_PAGE_PGNO(pNews[nNews - 1]);
|
||||
} else {
|
||||
((SPgno *)pDivCell[nOlds - 1])[0] = TDB_PAGE_PGNO(pNews[nNews - 1]);
|
||||
(void)tdbPageInsertCell(pParent, sIdx, pDivCell[nOlds - 1], szDivCell[nOlds - 1], 0);
|
||||
ret = tdbPageInsertCell(pParent, sIdx, pDivCell[nOlds - 1], szDivCell[nOlds - 1], 0);
|
||||
if (ret) {
|
||||
tdbError("tdb/btree-balance: insert cell failed with ret: %d.", ret);
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < nOlds; i++) {
|
||||
(void)tdbPageDestroy(pOldsCopy[i], tdbDefaultFree, NULL);
|
||||
tdbPageDestroy(pOldsCopy[i], tdbDefaultFree, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (TDB_BTREE_PAGE_IS_ROOT(pParent) && TDB_PAGE_TOTAL_CELLS(pParent) == 0) {
|
||||
i8 flags = TDB_BTREE_ROOT | TDB_BTREE_PAGE_IS_LEAF(pNews[0]);
|
||||
// copy content to the parent page
|
||||
(void)tdbBtreeInitPage(pParent, &(SBtreeInitPageArg){.flags = flags, .pBt = pBt}, 0);
|
||||
(void)tdbPageCopy(pNews[0], pParent, 1);
|
||||
ret = tdbBtreeInitPage(pParent, &(SBtreeInitPageArg){.flags = flags, .pBt = pBt}, 0);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
ret = tdbPageCopy(pNews[0], pParent, 1);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!TDB_BTREE_PAGE_IS_LEAF(pNews[0])) {
|
||||
((SIntHdr *)(pParent->pData))->pgno = ((SIntHdr *)(pNews[0]->pData))->pgno;
|
||||
}
|
||||
|
||||
(void)tdbPagerInsertFreePage(pBt->pPager, pNews[0], pTxn);
|
||||
ret = tdbPagerInsertFreePage(pBt->pPager, pNews[0], pTxn);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
@ -1991,7 +2043,11 @@ int tdbBtcMoveToNext(SBTC *pBtc) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
(void)tdbBtcMoveUpward(pBtc);
|
||||
ret = tdbBtcMoveUpward(pBtc);
|
||||
if (ret < 0) {
|
||||
tdbError("tdb/btc-move-to-next: btc move upward failed with ret: %d.", ret);
|
||||
return ret;
|
||||
}
|
||||
pBtc->idx++;
|
||||
|
||||
if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) {
|
||||
|
@ -2020,6 +2076,7 @@ int tdbBtcMoveToNext(SBTC *pBtc) {
|
|||
}
|
||||
|
||||
int tdbBtcMoveToPrev(SBTC *pBtc) {
|
||||
int32_t ret = 0;
|
||||
if (pBtc->idx < 0) return TSDB_CODE_FAILED;
|
||||
|
||||
pBtc->idx--;
|
||||
|
@ -2034,7 +2091,11 @@ int tdbBtcMoveToPrev(SBTC *pBtc) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
(void)tdbBtcMoveUpward(pBtc);
|
||||
ret = tdbBtcMoveUpward(pBtc);
|
||||
if (ret < 0) {
|
||||
tdbError("tdb/btc-move-to-prev: btc move upward failed with ret: %d.", ret);
|
||||
return ret;
|
||||
}
|
||||
pBtc->idx--;
|
||||
if (pBtc->idx >= 0) {
|
||||
break;
|
||||
|
@ -2045,7 +2106,11 @@ int tdbBtcMoveToPrev(SBTC *pBtc) {
|
|||
for (;;) {
|
||||
if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) break;
|
||||
|
||||
(void)tdbBtcMoveDownward(pBtc);
|
||||
ret = tdbBtcMoveDownward(pBtc);
|
||||
if (ret < 0) {
|
||||
tdbError("tdb/btc-move-to-prev: btc move downward failed with ret: %d.", ret);
|
||||
return ret;
|
||||
}
|
||||
if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) {
|
||||
pBtc->idx = TDB_PAGE_TOTAL_CELLS(pBtc->pPage) - 1;
|
||||
} else {
|
||||
|
@ -2167,6 +2232,9 @@ int tdbBtcDelete(SBTC *pBtc) {
|
|||
bool destroyOfps = false;
|
||||
if (!pBtc->pPage->pPager->ofps) {
|
||||
pBtc->pPage->pPager->ofps = taosArrayInit(8, sizeof(SPage *));
|
||||
if (pBtc->pPage->pPager->ofps == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
destroyOfps = true;
|
||||
}
|
||||
|
||||
|
@ -2189,7 +2257,11 @@ int tdbBtcDelete(SBTC *pBtc) {
|
|||
if (idx == nCells - 1) {
|
||||
if (idx) {
|
||||
pBtc->idx--;
|
||||
(void)tdbBtcGet(pBtc, &pKey, &nKey, NULL, NULL);
|
||||
ret = tdbBtcGet(pBtc, &pKey, &nKey, NULL, NULL);
|
||||
if (ret) {
|
||||
tdbError("tdb/btc-delete: btc get failed with ret: %d.", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// loop to update the interial page
|
||||
pgno = TDB_PAGE_PGNO(pBtc->pPage);
|
||||
|
@ -2440,7 +2512,11 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
|
|||
|
||||
// compare first cell
|
||||
pBtc->idx = lidx;
|
||||
(void)tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL);
|
||||
ret = tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL);
|
||||
if (ret < 0) {
|
||||
tdbError("tdb/btc-move-to: btc get failed with ret: %d.", ret);
|
||||
return ret;
|
||||
}
|
||||
c = pBt->kcmpr(pKey, kLen, pTKey, tkLen);
|
||||
if (c <= 0) {
|
||||
ridx = lidx - 1;
|
||||
|
@ -2450,7 +2526,11 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
|
|||
// compare last cell
|
||||
if (lidx <= ridx) {
|
||||
pBtc->idx = ridx;
|
||||
(void)tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL);
|
||||
ret = tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL);
|
||||
if (ret < 0) {
|
||||
tdbError("tdb/btc-move-to: btc get failed with ret: %d.", ret);
|
||||
return ret;
|
||||
}
|
||||
c = pBt->kcmpr(pKey, kLen, pTKey, tkLen);
|
||||
if (c >= 0) {
|
||||
lidx = ridx + 1;
|
||||
|
@ -2465,7 +2545,11 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
|
|||
if (lidx > ridx) break;
|
||||
|
||||
pBtc->idx = (lidx + ridx) >> 1;
|
||||
(void)tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL);
|
||||
ret = tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL);
|
||||
if (ret < 0) {
|
||||
tdbError("tdb/btc-move-to: btc get failed with ret: %d.", ret);
|
||||
return ret;
|
||||
}
|
||||
c = pBt->kcmpr(pKey, kLen, pTKey, tkLen);
|
||||
if (c < 0) {
|
||||
// pKey < cd.pKey
|
||||
|
@ -2499,18 +2583,18 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int tdbBtcClose(SBTC *pBtc) {
|
||||
void tdbBtcClose(SBTC *pBtc) {
|
||||
if (pBtc->iPage < 0) {
|
||||
if (pBtc->freeTxn) {
|
||||
tdbTxnClose(pBtc->pTxn);
|
||||
}
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
if (NULL == pBtc->pPage) {
|
||||
tdbError("tdb/btc-close: null ptr pPage.");
|
||||
return TSDB_CODE_FAILED;
|
||||
return;
|
||||
}
|
||||
|
||||
tdbPagerReturnPage(pBtc->pBt->pPager, pBtc->pPage, pBtc->pTxn);
|
||||
|
@ -2536,7 +2620,7 @@ int tdbBtcClose(SBTC *pBtc) {
|
|||
tdbTxnClose(pBtc->pTxn);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
int tdbBtcIsValid(SBTC *pBtc) {
|
||||
|
|
|
@ -149,7 +149,7 @@ static int tdbPCacheAlterImpl(SPCache *pCache, int32_t nPage) {
|
|||
SPage *pPage = *ppPage;
|
||||
*ppPage = pPage->pFreeNext;
|
||||
pCache->aPage[pPage->id] = NULL;
|
||||
(void)tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
||||
tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
||||
pCache->nFree--;
|
||||
} else {
|
||||
ppPage = &(*ppPage)->pFreeNext;
|
||||
|
@ -209,7 +209,7 @@ static void tdbPCacheFreePage(SPCache *pCache, SPage *pPage) {
|
|||
tdbTrace("pcache/free2 page: %p/%d, pgno:%d, ", pPage, pPage->id, TDB_PAGE_PGNO(pPage));
|
||||
|
||||
tdbPCacheRemovePageFromHash(pCache, pPage);
|
||||
(void)tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
||||
tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,7 @@ void tdbPCacheRelease(SPCache *pCache, SPage *pPage, TXN *pTxn) {
|
|||
tdbPCacheRemovePageFromHash(pCache, pPage);
|
||||
}
|
||||
|
||||
(void)tdbPageDestroy(pPage, pTxn->xFree, pTxn->xArg);
|
||||
tdbPageDestroy(pPage, pTxn->xFree, pTxn->xArg);
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ static void tdbPCacheUnpinPage(SPCache *pCache, SPage *pPage) {
|
|||
tdbTrace("pcache destroy page: %p/%d/%d", pPage, TDB_PAGE_PGNO(pPage), pPage->id);
|
||||
|
||||
tdbPCacheRemovePageFromHash(pCache, pPage);
|
||||
(void)tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
||||
tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -518,14 +518,14 @@ static int tdbPCacheCloseImpl(SPCache *pCache) {
|
|||
// free free page
|
||||
for (SPage *pPage = pCache->pFree; pPage;) {
|
||||
SPage *pPageT = pPage->pFreeNext;
|
||||
(void)tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
||||
tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
||||
pPage = pPageT;
|
||||
}
|
||||
|
||||
for (int32_t iBucket = 0; iBucket < pCache->nHash; iBucket++) {
|
||||
for (SPage *pPage = pCache->pgHash[iBucket]; pPage;) {
|
||||
SPage *pPageT = pPage->pHashNext;
|
||||
(void)tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
||||
tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
||||
pPage = pPageT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,19 +79,19 @@ int tdbPageCreate(int pageSize, SPage **ppPage, void *(*xMalloc)(void *, size_t)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int tdbPageDestroy(SPage *pPage, void (*xFree)(void *arg, void *ptr), void *arg) {
|
||||
void tdbPageDestroy(SPage *pPage, void (*xFree)(void *arg, void *ptr), void *arg) {
|
||||
u8 *ptr;
|
||||
|
||||
tdbTrace("tdb/page-destroy: %p/%d %p", pPage, pPage->id, xFree);
|
||||
|
||||
if (pPage->isDirty) {
|
||||
tdbError("tdb/page-destroy: dirty page: %" PRIu8 ".", pPage->isDirty);
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!xFree) {
|
||||
tdbError("tdb/page-destroy: null xFree.");
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
return;
|
||||
}
|
||||
|
||||
for (int iOvfl = 0; iOvfl < pPage->nOverflow; iOvfl++) {
|
||||
|
@ -102,7 +102,7 @@ int tdbPageDestroy(SPage *pPage, void (*xFree)(void *arg, void *ptr), void *arg)
|
|||
ptr = pPage->pData;
|
||||
xFree(arg, ptr);
|
||||
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
void tdbPageZero(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell *, int, TXN *, SBTree *pBt)) {
|
||||
|
@ -156,6 +156,7 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl
|
|||
int iOvfl;
|
||||
int lidx; // local idx
|
||||
SCell *pNewCell;
|
||||
int ret;
|
||||
|
||||
if (szCell > TDB_PAGE_MAX_FREE_BLOCK(pPage, pPage->pPageHdr - pPage->pData)) {
|
||||
tdbError("tdb/page-insert-cell: invalid page, szCell: %d, max free: %lu", szCell,
|
||||
|
@ -198,7 +199,11 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl
|
|||
iOvfl++;
|
||||
} else {
|
||||
// page must has enough space to hold the cell locally
|
||||
(void)tdbPageAllocate(pPage, szCell, &pNewCell);
|
||||
ret = tdbPageAllocate(pPage, szCell, &pNewCell);
|
||||
if (ret) {
|
||||
tdbError("tdb/page-insert-cell: allocate cell failed, idx: %d, szCell: %d", idx, szCell);
|
||||
return ret;
|
||||
}
|
||||
|
||||
memcpy(pNewCell, pCell, szCell);
|
||||
|
||||
|
@ -224,7 +229,9 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl
|
|||
}
|
||||
|
||||
int tdbPageUpdateCell(SPage *pPage, int idx, SCell *pCell, int szCell, TXN *pTxn, SBTree *pBt) {
|
||||
(void)tdbPageDropCell(pPage, idx, pTxn, pBt);
|
||||
int ret = tdbPageDropCell(pPage, idx, pTxn, pBt);
|
||||
if (ret) return ret;
|
||||
|
||||
return tdbPageInsertCell(pPage, idx, pCell, szCell, 0);
|
||||
}
|
||||
|
||||
|
@ -234,6 +241,7 @@ int tdbPageDropCell(SPage *pPage, int idx, TXN *pTxn, SBTree *pBt) {
|
|||
int szCell;
|
||||
int nCells;
|
||||
int iOvfl;
|
||||
int ret;
|
||||
|
||||
nCells = TDB_PAGE_NCELLS(pPage);
|
||||
|
||||
|
@ -263,9 +271,12 @@ int tdbPageDropCell(SPage *pPage, int idx, TXN *pTxn, SBTree *pBt) {
|
|||
lidx = idx - iOvfl;
|
||||
pCell = TDB_PAGE_CELL_AT(pPage, lidx);
|
||||
szCell = (*pPage->xCellSize)(pPage, pCell, 1, pTxn, pBt);
|
||||
(void)tdbPageFree(pPage, lidx, pCell, szCell);
|
||||
ret = tdbPageFree(pPage, lidx, pCell, szCell);
|
||||
if (ret) {
|
||||
tdbError("tdb/page-drop-cell: free cell failed, idx: %d, lidx: %d, szCell: %d", idx, lidx, szCell);
|
||||
return ret;
|
||||
}
|
||||
TDB_PAGE_NCELLS_SET(pPage, nCells - 1);
|
||||
|
||||
for (; iOvfl < pPage->nOverflow; iOvfl++) {
|
||||
pPage->aiOvfl[iOvfl]--;
|
||||
if (pPage->aiOvfl[iOvfl] <= 0) {
|
||||
|
|
|
@ -802,7 +802,7 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) {
|
|||
code = tdbTbcMoveToFirst(pCur);
|
||||
if (code) {
|
||||
tdbError("tdb/remove-free-page: moveto first failed with ret: %d.", code);
|
||||
(void)tdbTbcClose(pCur);
|
||||
tdbTbcClose(pCur);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -812,7 +812,7 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) {
|
|||
code = tdbTbcGet(pCur, (const void **)&pKey, &nKey, NULL, NULL);
|
||||
if (code < 0) {
|
||||
// tdbError("tdb/remove-free-page: tbc get failed with ret: %d.", code);
|
||||
(void)tdbTbcClose(pCur);
|
||||
tdbTbcClose(pCur);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -823,10 +823,10 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) {
|
|||
code = tdbTbcDelete(pCur);
|
||||
if (code < 0) {
|
||||
tdbError("tdb/remove-free-page: tbc delete failed with ret: %d.", code);
|
||||
(void)tdbTbcClose(pCur);
|
||||
tdbTbcClose(pCur);
|
||||
return 0;
|
||||
}
|
||||
(void)tdbTbcClose(pCur);
|
||||
tdbTbcClose(pCur);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1165,14 +1165,14 @@ int tdbPagerRestoreJournals(SPager *pPager) {
|
|||
code = tdbPagerRestore(pPager, jname);
|
||||
if (code) {
|
||||
taosArrayDestroy(pTxnList);
|
||||
(void)tdbCloseDir(&pDir);
|
||||
tdbCloseDir(&pDir);
|
||||
tdbError("failed to restore file due to %s. jFileName:%s", tstrerror(code), jname);
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
taosArrayDestroy(pTxnList);
|
||||
(void)tdbCloseDir(&pDir);
|
||||
tdbCloseDir(&pDir);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1195,7 +1195,7 @@ int tdbPagerRollback(SPager *pPager) {
|
|||
jname[dirLen] = '/';
|
||||
memcpy(jname + dirLen + 1, name, strlen(name));
|
||||
if (tdbOsRemove(jname) < 0 && errno != ENOENT) {
|
||||
(void)tdbCloseDir(&pDir);
|
||||
tdbCloseDir(&pDir);
|
||||
|
||||
tdbError("failed to remove file due to %s. jFileName:%s", strerror(errno), name);
|
||||
return terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
|
@ -1203,7 +1203,7 @@ int tdbPagerRollback(SPager *pPager) {
|
|||
}
|
||||
}
|
||||
|
||||
(void)tdbCloseDir(&pDir);
|
||||
tdbCloseDir(&pDir);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF
|
|||
|
||||
int tdbTbClose(TTB *pTb) {
|
||||
if (pTb) {
|
||||
(void)tdbBtreeClose(pTb->pBt);
|
||||
tdbBtreeClose(pTb->pBt);
|
||||
tdbOsFree(pTb);
|
||||
}
|
||||
return 0;
|
||||
|
@ -260,7 +260,7 @@ int32_t tdbTbTraversal(TTB *pTb, void *data,
|
|||
}
|
||||
tdbFree(pKey);
|
||||
tdbFree(pValue);
|
||||
(void)tdbTbcClose(pCur);
|
||||
tdbTbcClose(pCur);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -293,13 +293,11 @@ int tdbTbcUpsert(TBC *pTbc, const void *pKey, int nKey, const void *pData, int n
|
|||
return tdbBtcUpsert(&pTbc->btc, pKey, nKey, pData, nData, insert);
|
||||
}
|
||||
|
||||
int tdbTbcClose(TBC *pTbc) {
|
||||
void tdbTbcClose(TBC *pTbc) {
|
||||
if (pTbc) {
|
||||
(void)tdbBtcClose(&pTbc->btc);
|
||||
tdbBtcClose(&pTbc->btc);
|
||||
tdbOsFree(pTbc);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tdbTbcIsValid(TBC *pTbc) { return tdbBtcIsValid(&pTbc->btc); }
|
||||
|
|
|
@ -27,17 +27,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
extern int32_t tdbDebugFlag;
|
||||
|
||||
#define tdbFatal(...) do { if (tdbDebugFlag & DEBUG_FATAL) { taosPrintLog("TDB FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} while(0)
|
||||
#define tdbError(...) do { if (tdbDebugFlag & DEBUG_ERROR) { taosPrintLog("TDB ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while(0)
|
||||
#define tdbWarn(...) do { if (tdbDebugFlag & DEBUG_WARN) { taosPrintLog("TDB WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} while(0)
|
||||
#define tdbInfo(...) do { if (tdbDebugFlag & DEBUG_INFO) { taosPrintLog("TDB ", DEBUG_INFO, 255, __VA_ARGS__); }} while(0)
|
||||
#define tdbDebug(...) do { if (tdbDebugFlag & DEBUG_DEBUG) { taosPrintLog("TDB ", DEBUG_DEBUG, tdbDebugFlag, __VA_ARGS__); }} while(0)
|
||||
#define tdbTrace(...) do { if (tdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TDB ", DEBUG_TRACE, tdbDebugFlag, __VA_ARGS__); }} while(0)
|
||||
// clang-format on
|
||||
|
||||
typedef int8_t i8;
|
||||
typedef int16_t i16;
|
||||
typedef int32_t i32;
|
||||
|
@ -156,11 +145,11 @@ struct SBTC {
|
|||
};
|
||||
|
||||
// SBTree
|
||||
int tdbBtreeOpen(int keyLen, int valLen, SPager *pFile, char const *tbname, SPgno pgno, tdb_cmpr_fn_t kcmpr, TDB *pEnv,
|
||||
SBTree **ppBt);
|
||||
int tdbBtreeClose(SBTree *pBt);
|
||||
int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, int vLen, TXN *pTxn);
|
||||
int tdbBtreeDelete(SBTree *pBt, const void *pKey, int kLen, TXN *pTxn);
|
||||
int tdbBtreeOpen(int keyLen, int valLen, SPager *pFile, char const *tbname, SPgno pgno, tdb_cmpr_fn_t kcmpr, TDB *pEnv,
|
||||
SBTree **ppBt);
|
||||
void tdbBtreeClose(SBTree *pBt);
|
||||
int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, int vLen, TXN *pTxn);
|
||||
int tdbBtreeDelete(SBTree *pBt, const void *pKey, int kLen, TXN *pTxn);
|
||||
// int tdbBtreeUpsert(SBTree *pBt, const void *pKey, int nKey, const void *pData, int nData, TXN *pTxn);
|
||||
int tdbBtreeGet(SBTree *pBt, const void *pKey, int kLen, void **ppVal, int *vLen);
|
||||
int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkLen, void **ppVal, int *vLen);
|
||||
|
@ -173,19 +162,19 @@ typedef struct {
|
|||
int tdbBtreeInitPage(SPage *pPage, void *arg, int init);
|
||||
|
||||
// SBTC
|
||||
int tdbBtcOpen(SBTC *pBtc, SBTree *pBt, TXN *pTxn);
|
||||
int tdbBtcClose(SBTC *pBtc);
|
||||
int tdbBtcIsValid(SBTC *pBtc);
|
||||
int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst);
|
||||
int tdbBtcMoveToFirst(SBTC *pBtc);
|
||||
int tdbBtcMoveToLast(SBTC *pBtc);
|
||||
int tdbBtcMoveToNext(SBTC *pBtc);
|
||||
int tdbBtcMoveToPrev(SBTC *pBtc);
|
||||
int tdbBtreeNext(SBTC *pBtc, void **ppKey, int *kLen, void **ppVal, int *vLen);
|
||||
int tdbBtreePrev(SBTC *pBtc, void **ppKey, int *kLen, void **ppVal, int *vLen);
|
||||
int tdbBtcGet(SBTC *pBtc, const void **ppKey, int *kLen, const void **ppVal, int *vLen);
|
||||
int tdbBtcDelete(SBTC *pBtc);
|
||||
int tdbBtcUpsert(SBTC *pBtc, const void *pKey, int kLen, const void *pData, int nData, int insert);
|
||||
int tdbBtcOpen(SBTC *pBtc, SBTree *pBt, TXN *pTxn);
|
||||
void tdbBtcClose(SBTC *pBtc);
|
||||
int tdbBtcIsValid(SBTC *pBtc);
|
||||
int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst);
|
||||
int tdbBtcMoveToFirst(SBTC *pBtc);
|
||||
int tdbBtcMoveToLast(SBTC *pBtc);
|
||||
int tdbBtcMoveToNext(SBTC *pBtc);
|
||||
int tdbBtcMoveToPrev(SBTC *pBtc);
|
||||
int tdbBtreeNext(SBTC *pBtc, void **ppKey, int *kLen, void **ppVal, int *vLen);
|
||||
int tdbBtreePrev(SBTC *pBtc, void **ppKey, int *kLen, void **ppVal, int *vLen);
|
||||
int tdbBtcGet(SBTC *pBtc, const void **ppKey, int *kLen, const void **ppVal, int *vLen);
|
||||
int tdbBtcDelete(SBTC *pBtc);
|
||||
int tdbBtcUpsert(SBTC *pBtc, const void *pKey, int kLen, const void *pData, int nData, int insert);
|
||||
|
||||
// tdbPager.c ====================================
|
||||
|
||||
|
@ -339,7 +328,7 @@ static inline int tdbTryLockPage(tdb_spinlock_t *pLock) {
|
|||
#define TDB_PAGE_OFFSET_SIZE(pPage) ((pPage)->pPageMethods->szOffset)
|
||||
|
||||
int tdbPageCreate(int pageSize, SPage **ppPage, void *(*xMalloc)(void *, size_t), void *arg);
|
||||
int tdbPageDestroy(SPage *pPage, void (*xFree)(void *arg, void *ptr), void *arg);
|
||||
void tdbPageDestroy(SPage *pPage, void (*xFree)(void *arg, void *ptr), void *arg);
|
||||
void tdbPageZero(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell *, int, TXN *, SBTree *pBt));
|
||||
void tdbPageInit(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell *, int, TXN *, SBTree *pBt));
|
||||
int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl);
|
||||
|
|
|
@ -27,6 +27,17 @@ extern "C" {
|
|||
#include "os.h"
|
||||
#include "thash.h"
|
||||
|
||||
// clang-format off
|
||||
extern int32_t tdbDebugFlag;
|
||||
|
||||
#define tdbFatal(...) do { if (tdbDebugFlag & DEBUG_FATAL) { taosPrintLog("TDB FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} while(0)
|
||||
#define tdbError(...) do { if (tdbDebugFlag & DEBUG_ERROR) { taosPrintLog("TDB ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while(0)
|
||||
#define tdbWarn(...) do { if (tdbDebugFlag & DEBUG_WARN) { taosPrintLog("TDB WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} while(0)
|
||||
#define tdbInfo(...) do { if (tdbDebugFlag & DEBUG_INFO) { taosPrintLog("TDB ", DEBUG_INFO, 255, __VA_ARGS__); }} while(0)
|
||||
#define tdbDebug(...) do { if (tdbDebugFlag & DEBUG_DEBUG) { taosPrintLog("TDB ", DEBUG_DEBUG, tdbDebugFlag, __VA_ARGS__); }} while(0)
|
||||
#define tdbTrace(...) do { if (tdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TDB ", DEBUG_TRACE, tdbDebugFlag, __VA_ARGS__); }} while(0)
|
||||
// clang-format on
|
||||
|
||||
// For memory -----------------
|
||||
#define tdbOsMalloc taosMemoryMalloc
|
||||
#define tdbOsCalloc taosMemoryCalloc
|
||||
|
@ -59,9 +70,16 @@ typedef TdFilePtr tdb_fd_t;
|
|||
#define tdbReadDir taosReadDir
|
||||
#define tdbGetDirEntryName taosGetDirEntryName
|
||||
#define tdbDirEntryBaseName taosDirEntryBaseName
|
||||
#define tdbCloseDir taosCloseDir
|
||||
#define tdbOsRemove remove
|
||||
#define tdbOsFileSize(FD, PSIZE) taosFStatFile(FD, PSIZE, NULL)
|
||||
|
||||
static FORCE_INLINE void tdbCloseDir(TdDirPtr *ppDir) {
|
||||
int32_t ret = taosCloseDir(ppDir);
|
||||
if (ret) {
|
||||
tdbError("failed to close directory, reason:%s", tstrerror(ret));
|
||||
}
|
||||
}
|
||||
|
||||
#define tdbOsRemove remove
|
||||
#define tdbOsFileSize(FD, PSIZE) taosFStatFile(FD, PSIZE, NULL)
|
||||
|
||||
/* directory */
|
||||
#define tdbOsMkdir taosMkDir
|
||||
|
|
Loading…
Reference in New Issue