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 节。
|
- stb_name 是保存计算结果的超级表的表名,如果该超级表不存在,则会自动创建;如果已存在,则检查列的 schema 信息。详见 6.3.8 节。
|
||||||
- tags 子句定义了流计算中创建标签的规则。通过 tags 字段可以为每个分区对应的子表生成自定义的标签值。
|
- 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_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(1000, 500) SLIDING(1000), 不带时间单位的形式,将使用查询库的时间精度作为默认时间单位,当存在多个库时默认采用精度更高的库.
|
||||||
- INTERVAL('1s', '500a') SLIDING('1s'), 自带时间单位的字符串形式,字符串内部不能有任何空格等其它字符.
|
- INTERVAL('1s', '500a') SLIDING('1s'), 自带时间单位的字符串形式,字符串内部不能有任何空格等其它字符.
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ time_duration:
|
||||||
number unit
|
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.
|
其中 TSMA 命名规则与表名字类似, 长度最大限制为表名长度限制减去输出表后缀长度, 表名长度限制为193, 输出表后缀为`_tsma_res_stb_`, TSMA 名字最大长度为178.
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ TSMA只能基于超级表和普通表创建, 不能基于子表创建.
|
||||||
|
|
||||||
由于TSMA输出为一张超级表, 因此输出表的行长度受最大行长度限制, 不同函数的`中间结果`大小各异, 一般都大于原始数据大小, 若输出表的行长度大于最大行长度限制, 将会报`Row length exceeds max length`错误. 此时需要减少函数个数或者将常用的函数进行分组拆分到多个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条数也受当前已经存在的流条数和最大可创建流条数限制.
|
TSMA为库内对象, 但名字全局唯一. 集群内一共可创建TSMA个数受参数`maxTsmaNum`限制, 参数默认值为3, 范围: [0-3]. 注意, 由于TSMA后台计算使用流计算, 因此每创建一条TSMA, 将会创建一条流, 因此能够创建的TSMA条数也受当前已经存在的流条数和最大可创建流条数限制.
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ typedef struct SStoreCacheReader {
|
||||||
SArray *pFuncTypeList, SColumnInfo* pPkCol, int32_t numOfPks);
|
SArray *pFuncTypeList, SColumnInfo* pPkCol, int32_t numOfPks);
|
||||||
void (*closeReader)(void *pReader);
|
void (*closeReader)(void *pReader);
|
||||||
int32_t (*retrieveRows)(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, const int32_t *dstSlotIds,
|
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);
|
int32_t (*reuseReader)(void *pReader, void *pTableIdList, int32_t numOfTables);
|
||||||
} SStoreCacheReader;
|
} SStoreCacheReader;
|
||||||
|
|
||||||
|
|
|
@ -552,6 +552,9 @@ int32_t createRequest(uint64_t connId, int32_t type, int64_t reqid, SRequestObj
|
||||||
(*pRequest)->allocatorRefId = -1;
|
(*pRequest)->allocatorRefId = -1;
|
||||||
|
|
||||||
(*pRequest)->pDb = getDbOfConnection(pTscObj);
|
(*pRequest)->pDb = getDbOfConnection(pTscObj);
|
||||||
|
if (NULL == (*pRequest)->pDb) {
|
||||||
|
TSC_ERR_JRET(terrno);
|
||||||
|
}
|
||||||
(*pRequest)->pTscObj = pTscObj;
|
(*pRequest)->pTscObj = pTscObj;
|
||||||
(*pRequest)->inCallback = false;
|
(*pRequest)->inCallback = false;
|
||||||
(*pRequest)->msgBuf = taosMemoryCalloc(1, ERROR_MSG_BUF_DEFAULT_SIZE);
|
(*pRequest)->msgBuf = taosMemoryCalloc(1, ERROR_MSG_BUF_DEFAULT_SIZE);
|
||||||
|
|
|
@ -1359,6 +1359,14 @@ static void *hbThreadFunc(void *param) {
|
||||||
pInfo->msgInfo.len = tlen;
|
pInfo->msgInfo.len = tlen;
|
||||||
pInfo->msgType = TDMT_MND_HEARTBEAT;
|
pInfo->msgType = TDMT_MND_HEARTBEAT;
|
||||||
pInfo->param = taosMemoryMalloc(sizeof(int32_t));
|
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;
|
*(int32_t *)pInfo->param = i;
|
||||||
pInfo->paramFreeFp = taosMemoryFree;
|
pInfo->paramFreeFp = taosMemoryFree;
|
||||||
pInfo->requestId = generateRequestId();
|
pInfo->requestId = generateRequestId();
|
||||||
|
|
|
@ -1291,7 +1291,7 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
pRequest->code = terrno;
|
pRequest->code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
|
@ -1586,6 +1586,8 @@ int32_t taosConnectImpl(const char* user, const char* auth, const char* db, __ta
|
||||||
pRequest->sqlstr = taosStrdup("taos_connect");
|
pRequest->sqlstr = taosStrdup("taos_connect");
|
||||||
if (pRequest->sqlstr) {
|
if (pRequest->sqlstr) {
|
||||||
pRequest->sqlLen = strlen(pRequest->sqlstr);
|
pRequest->sqlLen = strlen(pRequest->sqlstr);
|
||||||
|
} else {
|
||||||
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMsgSendInfo* body = NULL;
|
SMsgSendInfo* body = NULL;
|
||||||
|
@ -1649,6 +1651,9 @@ static int32_t buildConnectMsg(SRequestObj* pRequest, SMsgSendInfo** pMsgSendInf
|
||||||
char* db = getDbOfConnection(pObj);
|
char* db = getDbOfConnection(pObj);
|
||||||
if (db != NULL) {
|
if (db != NULL) {
|
||||||
tstrncpy(connectReq.db, db, sizeof(connectReq.db));
|
tstrncpy(connectReq.db, db, sizeof(connectReq.db));
|
||||||
|
} else if (terrno) {
|
||||||
|
taosMemoryFree(*pMsgSendInfo);
|
||||||
|
return terrno;
|
||||||
}
|
}
|
||||||
taosMemoryFreeClear(db);
|
taosMemoryFreeClear(db);
|
||||||
|
|
||||||
|
@ -2396,11 +2401,16 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
|
||||||
}
|
}
|
||||||
|
|
||||||
char* getDbOfConnection(STscObj* pObj) {
|
char* getDbOfConnection(STscObj* pObj) {
|
||||||
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
char* p = NULL;
|
char* p = NULL;
|
||||||
(void)taosThreadMutexLock(&pObj->mutex);
|
(void)taosThreadMutexLock(&pObj->mutex);
|
||||||
size_t len = strlen(pObj->db);
|
size_t len = strlen(pObj->db);
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
p = strndup(pObj->db, tListLen(pObj->db));
|
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);
|
(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 *pCidList, int32_t *pSlotIds, uint64_t suid, void **pReader, const char *idstr,
|
||||||
SArray *pFuncTypeList, SColumnInfo *pkCol, int32_t numOfPks);
|
SArray *pFuncTypeList, SColumnInfo *pkCol, int32_t numOfPks);
|
||||||
int32_t tsdbRetrieveCacheRows(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, const int32_t *dstSlotIds,
|
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 tsdbCacherowsReaderClose(void *pReader);
|
||||||
|
|
||||||
void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity);
|
void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity);
|
||||||
|
|
|
@ -260,7 +260,7 @@ void metaCloseTbCursor(SMTbCursor *pTbCur) {
|
||||||
if (!pTbCur->paused) {
|
if (!pTbCur->paused) {
|
||||||
metaReaderClear(&pTbCur->mr);
|
metaReaderClear(&pTbCur->mr);
|
||||||
if (pTbCur->pDbc) {
|
if (pTbCur->pDbc) {
|
||||||
(void)tdbTbcClose((TBC *)pTbCur->pDbc);
|
tdbTbcClose((TBC *)pTbCur->pDbc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taosMemoryFree(pTbCur);
|
taosMemoryFree(pTbCur);
|
||||||
|
@ -270,7 +270,7 @@ void metaCloseTbCursor(SMTbCursor *pTbCur) {
|
||||||
void metaPauseTbCursor(SMTbCursor *pTbCur) {
|
void metaPauseTbCursor(SMTbCursor *pTbCur) {
|
||||||
if (!pTbCur->paused) {
|
if (!pTbCur->paused) {
|
||||||
metaReaderClear(&pTbCur->mr);
|
metaReaderClear(&pTbCur->mr);
|
||||||
(void)tdbTbcClose((TBC *)pTbCur->pDbc);
|
tdbTbcClose((TBC *)pTbCur->pDbc);
|
||||||
pTbCur->paused = 1;
|
pTbCur->paused = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -463,7 +463,7 @@ void metaCloseCtbCursor(SMCtbCursor *pCtbCur) {
|
||||||
if (!pCtbCur->paused) {
|
if (!pCtbCur->paused) {
|
||||||
if (pCtbCur->pMeta && pCtbCur->lock) metaULock(pCtbCur->pMeta);
|
if (pCtbCur->pMeta && pCtbCur->lock) metaULock(pCtbCur->pMeta);
|
||||||
if (pCtbCur->pCur) {
|
if (pCtbCur->pCur) {
|
||||||
(void)tdbTbcClose(pCtbCur->pCur);
|
tdbTbcClose(pCtbCur->pCur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tdbFree(pCtbCur->pKey);
|
tdbFree(pCtbCur->pKey);
|
||||||
|
@ -474,7 +474,7 @@ void metaCloseCtbCursor(SMCtbCursor *pCtbCur) {
|
||||||
|
|
||||||
void metaPauseCtbCursor(SMCtbCursor *pCtbCur) {
|
void metaPauseCtbCursor(SMCtbCursor *pCtbCur) {
|
||||||
if (!pCtbCur->paused) {
|
if (!pCtbCur->paused) {
|
||||||
(void)tdbTbcClose((TBC *)pCtbCur->pCur);
|
tdbTbcClose((TBC *)pCtbCur->pCur);
|
||||||
if (pCtbCur->lock) {
|
if (pCtbCur->lock) {
|
||||||
metaULock(pCtbCur->pMeta);
|
metaULock(pCtbCur->pMeta);
|
||||||
}
|
}
|
||||||
|
@ -582,7 +582,7 @@ void metaCloseStbCursor(SMStbCursor *pStbCur) {
|
||||||
if (pStbCur) {
|
if (pStbCur) {
|
||||||
if (pStbCur->pMeta) metaULock(pStbCur->pMeta);
|
if (pStbCur->pMeta) metaULock(pStbCur->pMeta);
|
||||||
if (pStbCur->pCur) {
|
if (pStbCur->pCur) {
|
||||||
(void)tdbTbcClose(pStbCur->pCur);
|
tdbTbcClose(pStbCur->pCur);
|
||||||
|
|
||||||
tdbFree(pStbCur->pKey);
|
tdbFree(pStbCur->pKey);
|
||||||
tdbFree(pStbCur->pVal);
|
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) {
|
if (tdbTbcMoveTo(pSkmDbC, &skmDbKey, sizeof(skmDbKey), &c) < 0) {
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
(void)tdbTbcClose(pSkmDbC);
|
tdbTbcClose(pSkmDbC);
|
||||||
code = TSDB_CODE_NOT_FOUND;
|
code = TSDB_CODE_NOT_FOUND;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
(void)tdbTbcClose(pSkmDbC);
|
tdbTbcClose(pSkmDbC);
|
||||||
code = TSDB_CODE_FAILED;
|
code = TSDB_CODE_FAILED;
|
||||||
metaError("meta/query: incorrect c: %" PRId32 ".", c);
|
metaError("meta/query: incorrect c: %" PRId32 ".", c);
|
||||||
goto _exit;
|
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) {
|
if (((SSkmDbKey *)pKey)->uid != skmDbKey.uid) {
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
(void)tdbTbcClose(pSkmDbC);
|
tdbTbcClose(pSkmDbC);
|
||||||
code = TSDB_CODE_NOT_FOUND;
|
code = TSDB_CODE_NOT_FOUND;
|
||||||
goto _exit;
|
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;
|
sver = ((SSkmDbKey *)pKey)->sver;
|
||||||
|
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
(void)tdbTbcClose(pSkmDbC);
|
tdbTbcClose(pSkmDbC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -817,7 +817,7 @@ void metaCloseSmaCursor(SMSmaCursor *pSmaCur) {
|
||||||
if (pSmaCur) {
|
if (pSmaCur) {
|
||||||
if (pSmaCur->pMeta) metaULock(pSmaCur->pMeta);
|
if (pSmaCur->pMeta) metaULock(pSmaCur->pMeta);
|
||||||
if (pSmaCur->pCur) {
|
if (pSmaCur->pCur) {
|
||||||
(void)tdbTbcClose(pSmaCur->pCur);
|
tdbTbcClose(pSmaCur->pCur);
|
||||||
pSmaCur->pCur = NULL;
|
pSmaCur->pCur = NULL;
|
||||||
|
|
||||||
tdbFree(pSmaCur->pKey);
|
tdbFree(pSmaCur->pKey);
|
||||||
|
@ -1117,7 +1117,7 @@ int32_t metaFilterCreateTime(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
||||||
|
|
||||||
END:
|
END:
|
||||||
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
||||||
if (pCursor->pCur) (void)tdbTbcClose(pCursor->pCur);
|
if (pCursor->pCur) tdbTbcClose(pCursor->pCur);
|
||||||
taosMemoryFree(pCursor);
|
taosMemoryFree(pCursor);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1192,7 +1192,7 @@ int32_t metaFilterTableName(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
||||||
|
|
||||||
END:
|
END:
|
||||||
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
||||||
if (pCursor->pCur) (void)tdbTbcClose(pCursor->pCur);
|
if (pCursor->pCur) tdbTbcClose(pCursor->pCur);
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
taosMemoryFree(pKey);
|
taosMemoryFree(pKey);
|
||||||
|
|
||||||
|
@ -1224,7 +1224,7 @@ int32_t metaFilterTtl(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
||||||
|
|
||||||
END:
|
END:
|
||||||
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
||||||
if (pCursor->pCur) (void)tdbTbcClose(pCursor->pCur);
|
if (pCursor->pCur) tdbTbcClose(pCursor->pCur);
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
taosMemoryFree(pKey);
|
taosMemoryFree(pKey);
|
||||||
|
|
||||||
|
@ -1401,7 +1401,7 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
||||||
|
|
||||||
END:
|
END:
|
||||||
if (pCursor->pMeta) metaULock(pCursor->pMeta);
|
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);
|
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
tdbFree(pData);
|
tdbFree(pData);
|
||||||
|
|
|
@ -59,7 +59,7 @@ _exit:
|
||||||
|
|
||||||
void metaSnapReaderClose(SMetaSnapReader** ppReader) {
|
void metaSnapReaderClose(SMetaSnapReader** ppReader) {
|
||||||
if (ppReader && *ppReader) {
|
if (ppReader && *ppReader) {
|
||||||
(void)tdbTbcClose((*ppReader)->pTbc);
|
tdbTbcClose((*ppReader)->pTbc);
|
||||||
taosMemoryFree(*ppReader);
|
taosMemoryFree(*ppReader);
|
||||||
*ppReader = NULL;
|
*ppReader = NULL;
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ static void destroySTableInfoForChildTable(void* data) {
|
||||||
|
|
||||||
static int32_t MoveToSnapShotVersion(SSnapContext* ctx) {
|
static int32_t MoveToSnapShotVersion(SSnapContext* ctx) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
(void)tdbTbcClose((TBC*)ctx->pCur);
|
tdbTbcClose((TBC*)ctx->pCur);
|
||||||
code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
return TAOS_GET_TERRNO(code);
|
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) {
|
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);
|
int32_t code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
return TAOS_GET_TERRNO(code);
|
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) {
|
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);
|
int32_t code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
return TAOS_GET_TERRNO(code);
|
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 destroySnapContext(SSnapContext* ctx) {
|
||||||
(void)tdbTbcClose((TBC*)ctx->pCur);
|
tdbTbcClose((TBC*)ctx->pCur);
|
||||||
taosArrayDestroy(ctx->idList);
|
taosArrayDestroy(ctx->idList);
|
||||||
taosHashCleanup(ctx->idVersion);
|
taosHashCleanup(ctx->idVersion);
|
||||||
taosHashCleanup(ctx->suidInfo);
|
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);
|
rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = pReq->suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
metaWLock(pMeta);
|
metaWLock(pMeta);
|
||||||
goto _drop_super_table;
|
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) {
|
if (taosArrayPush(tbUidList, &(((SCtbIdxKey *)pKey)->uid)) == NULL) {
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
|
|
||||||
(void)tsdbCacheDropSubTables(pMeta->pVnode->pTsdb, tbUidList, pReq->suid);
|
(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));
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL));
|
||||||
int rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
int rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
metaWLock(pMeta);
|
metaWLock(pMeta);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -454,14 +454,14 @@ static int32_t metaGetSubtables(SMeta *pMeta, int64_t suid, SArray *uids) {
|
||||||
|
|
||||||
if (taosArrayPush(uids, &(((SCtbIdxKey *)pKey)->uid)) == NULL) {
|
if (taosArrayPush(uids, &(((SCtbIdxKey *)pKey)->uid)) == NULL) {
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
|
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,14 +480,14 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL));
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL));
|
||||||
ret = tdbTbcMoveTo(pUidIdxc, &pReq->suid, sizeof(tb_uid_t), &c);
|
ret = tdbTbcMoveTo(pUidIdxc, &pReq->suid, sizeof(tb_uid_t), &c);
|
||||||
if (ret < 0 || c) {
|
if (ret < 0 || c) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
|
|
||||||
return terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
return terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData);
|
ret = tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
|
|
||||||
return terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
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));
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL));
|
||||||
ret = tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = pReq->suid, .version = oversion}), sizeof(STbDbKey), &c);
|
ret = tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = pReq->suid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||||
if (!(ret == 0 && c == 0)) {
|
if (!(ret == 0 && c == 0)) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
|
|
||||||
metaError("meta/table: invalide ret: %" PRId32 " or c: %" PRId32 "alter stb failed.", ret, c);
|
metaError("meta/table: invalide ret: %" PRId32 " or c: %" PRId32 "alter stb failed.", ret, c);
|
||||||
return terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
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);
|
ret = tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
|
|
||||||
return terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
return terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((oStbEntry.pBuf = taosMemoryMalloc(nData)) == NULL) {
|
if ((oStbEntry.pBuf = taosMemoryMalloc(nData)) == NULL) {
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
memcpy(oStbEntry.pBuf, pData, nData);
|
memcpy(oStbEntry.pBuf, pData, nData);
|
||||||
|
@ -541,8 +541,8 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
if (uids == NULL) {
|
if (uids == NULL) {
|
||||||
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
if (deltaCol == 1) {
|
if (deltaCol == 1) {
|
||||||
|
@ -603,8 +603,8 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
_exit:
|
_exit:
|
||||||
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
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);
|
code = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -705,7 +705,7 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
pCtbIdxc = NULL;
|
pCtbIdxc = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -740,7 +740,7 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
metaDestroyTagIdxKey(pTagIdxKey);
|
metaDestroyTagIdxKey(pTagIdxKey);
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -771,7 +771,7 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
tdbFree(pData);
|
tdbFree(pData);
|
||||||
|
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
_err:
|
_err:
|
||||||
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
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);
|
code = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -855,7 +855,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
pCtbIdxc = NULL;
|
pCtbIdxc = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -891,7 +891,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
metaDestroyTagIdxKey(pTagIdxKey);
|
metaDestroyTagIdxKey(pTagIdxKey);
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -919,7 +919,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
|
||||||
tDeleteSColCmprWrapper(cmpr);
|
tDeleteSColCmprWrapper(cmpr);
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -945,7 +945,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
tdbFree(pData);
|
tdbFree(pData);
|
||||||
|
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
_err:
|
_err:
|
||||||
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
||||||
|
@ -1217,7 +1217,7 @@ static int32_t metaFilterTableByHash(SMeta *pMeta, SArray *uidList) {
|
||||||
|
|
||||||
code = tdbTbcMoveToFirst(pCur);
|
code = tdbTbcMoveToFirst(pCur);
|
||||||
if (code) {
|
if (code) {
|
||||||
(void)tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1251,7 +1251,7 @@ static int32_t metaFilterTableByHash(SMeta *pMeta, SArray *uidList) {
|
||||||
}
|
}
|
||||||
tdbFree(pData);
|
tdbFree(pData);
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
(void)tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1537,7 +1537,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL));
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL));
|
||||||
(void)tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
(void)tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||||
if (c != 0) {
|
if (c != 0) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c);
|
metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c);
|
||||||
return TSDB_CODE_FAILED;
|
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));
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL));
|
||||||
(void)tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
(void)tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||||
if (c != 0) {
|
if (c != 0) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c);
|
metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c);
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -1570,8 +1570,8 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
tDecoderInit(&dc, entry.pBuf, nData);
|
tDecoderInit(&dc, entry.pBuf, nData);
|
||||||
ret = metaDecodeEntry(&dc, &entry);
|
ret = metaDecodeEntry(&dc, &entry);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
metaError("meta/table: invalide ret: %" PRId32 " alt tb column failed.", ret);
|
metaError("meta/table: invalide ret: %" PRId32 " alt tb column failed.", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1770,16 +1770,16 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
||||||
if (pNewSchema) taosMemoryFree(pNewSchema);
|
if (pNewSchema) taosMemoryFree(pNewSchema);
|
||||||
if (freeColCmpr) taosMemoryFree(entry.colCmpr.pColCmpr);
|
if (freeColCmpr) taosMemoryFree(entry.colCmpr.pColCmpr);
|
||||||
|
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
if (entry.pBuf) taosMemoryFree(entry.pBuf);
|
if (entry.pBuf) taosMemoryFree(entry.pBuf);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
|
|
||||||
return terrno != 0 ? terrno : TSDB_CODE_FAILED;
|
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));
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL));
|
||||||
(void)tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
(void)tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||||
if (c != 0) {
|
if (c != 0) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c);
|
metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c);
|
||||||
return terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
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));
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL));
|
||||||
(void)tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
(void)tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||||
if (c != 0) {
|
if (c != 0) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c);
|
metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c);
|
||||||
return terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST;
|
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);
|
taosMemoryFree((void *)ctbEntry.ctbEntry.pTags);
|
||||||
if (ctbEntry.pBuf) taosMemoryFree(ctbEntry.pBuf);
|
if (ctbEntry.pBuf) taosMemoryFree(ctbEntry.pBuf);
|
||||||
if (stbEntry.pBuf) tdbFree(stbEntry.pBuf);
|
if (stbEntry.pBuf) tdbFree(stbEntry.pBuf);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
|
@ -1977,8 +1977,8 @@ _err:
|
||||||
tDecoderClear(&dc2);
|
tDecoderClear(&dc2);
|
||||||
if (ctbEntry.pBuf) taosMemoryFree(ctbEntry.pBuf);
|
if (ctbEntry.pBuf) taosMemoryFree(ctbEntry.pBuf);
|
||||||
if (stbEntry.pBuf) tdbFree(stbEntry.pBuf);
|
if (stbEntry.pBuf) tdbFree(stbEntry.pBuf);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2009,7 +2009,7 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
||||||
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL));
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL));
|
||||||
(void)tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
(void)tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||||
if (c != 0) {
|
if (c != 0) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c);
|
metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c);
|
||||||
return TSDB_CODE_FAILED;
|
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));
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL));
|
||||||
(void)tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
(void)tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||||
if (c != 0) {
|
if (c != 0) {
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c);
|
metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c);
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -2043,8 +2043,8 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
||||||
ret = metaDecodeEntry(&dc, &entry);
|
ret = metaDecodeEntry(&dc, &entry);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
metaError("meta/table: invalide ret: %" PRId32 " alt tb options failed.", ret);
|
metaError("meta/table: invalide ret: %" PRId32 " alt tb options failed.", ret);
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -2081,8 +2081,8 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
||||||
|
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
|
|
||||||
(void)tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
(void)tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
if (entry.pBuf) taosMemoryFree(entry.pBuf);
|
if (entry.pBuf) taosMemoryFree(entry.pBuf);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2162,7 +2162,7 @@ static int metaAddTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTb
|
||||||
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL));
|
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL));
|
||||||
int rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
int rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -2199,14 +2199,14 @@ static int metaAddTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTb
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
metaDestroyTagIdxKey(pTagIdxKey);
|
metaDestroyTagIdxKey(pTagIdxKey);
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
(void)tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, pMeta->txn);
|
(void)tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, pMeta->txn);
|
||||||
metaDestroyTagIdxKey(pTagIdxKey);
|
metaDestroyTagIdxKey(pTagIdxKey);
|
||||||
pTagIdxKey = NULL;
|
pTagIdxKey = NULL;
|
||||||
}
|
}
|
||||||
(void)tdbTbcClose(pCtbIdxc);
|
tdbTbcClose(pCtbIdxc);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
|
@ -2320,7 +2320,7 @@ static int metaDropTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterT
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(void)tdbTbcClose(pTagIdxc);
|
tdbTbcClose(pTagIdxc);
|
||||||
|
|
||||||
metaWLock(pMeta);
|
metaWLock(pMeta);
|
||||||
for (int i = 0; i < taosArrayGetSize(tagIdxList); i++) {
|
for (int i = 0; i < taosArrayGetSize(tagIdxList); i++) {
|
||||||
|
|
|
@ -389,10 +389,7 @@ static int32_t tqMetaTransformInfo(TDB* pMetaDB, TTB* pOld, TTB* pNew) {
|
||||||
END:
|
END:
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
int32_t ret = tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
if (ret != 0) {
|
|
||||||
tqError("failed to close tbc, ret:%d", ret);
|
|
||||||
}
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,10 +461,7 @@ static int32_t tqMetaRestoreCheckInfo(STQ* pTq) {
|
||||||
END:
|
END:
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
int32_t ret = tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
if (ret != 0) {
|
|
||||||
tqError("failed to close tbc, ret:%d", ret);
|
|
||||||
}
|
|
||||||
tDeleteSTqCheckInfo(&info);
|
tDeleteSTqCheckInfo(&info);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,10 +77,7 @@ _err:
|
||||||
}
|
}
|
||||||
|
|
||||||
void tqSnapReaderClose(STqSnapReader** ppReader) {
|
void tqSnapReaderClose(STqSnapReader** ppReader) {
|
||||||
int32_t ret = tdbTbcClose((*ppReader)->pCur);
|
tdbTbcClose((*ppReader)->pCur);
|
||||||
if (ret != 0){
|
|
||||||
tqError("vgId:%d, vnode snapshot tq reader close failed since %s", TD_VID((*ppReader)->pTq->pVnode), tstrerror(ret));
|
|
||||||
}
|
|
||||||
taosMemoryFree(*ppReader);
|
taosMemoryFree(*ppReader);
|
||||||
*ppReader = NULL;
|
*ppReader = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,12 +97,8 @@ int32_t streamTaskSnapReaderClose(SStreamTaskReader* pReader) {
|
||||||
int32_t vgId = TD_VID(pReader->pTq->pVnode);
|
int32_t vgId = TD_VID(pReader->pTq->pVnode);
|
||||||
|
|
||||||
taosArrayDestroy(pReader->tdbTbList);
|
taosArrayDestroy(pReader->tdbTbList);
|
||||||
code = tdbTbcClose(pReader->pCur);
|
tdbTbcClose(pReader->pCur);
|
||||||
if (code) {
|
tqInfo("vgId:%d, vnode stream-task snapshot reader closed", vgId);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
taosMemoryFree(pReader);
|
taosMemoryFree(pReader);
|
||||||
return code;
|
return code;
|
||||||
|
@ -146,7 +142,7 @@ NextTbl:
|
||||||
}
|
}
|
||||||
if (except == 1) {
|
if (except == 1) {
|
||||||
if (pReader->pos + 1 < taosArrayGetSize(pReader->tdbTbList)) {
|
if (pReader->pos + 1 < taosArrayGetSize(pReader->tdbTbList)) {
|
||||||
(void)tdbTbcClose(pReader->pCur);
|
tdbTbcClose(pReader->pCur);
|
||||||
|
|
||||||
pReader->pos += 1;
|
pReader->pos += 1;
|
||||||
pPair = taosArrayGet(pReader->tdbTbList, pReader->pos);
|
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,
|
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) {
|
if (pReader == NULL || pResBlock == NULL) {
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
|
@ -642,7 +642,8 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
||||||
|
|
||||||
taosArrayDestroyEx(pLastCols, tsdbCacheFreeSLastColItem);
|
taosArrayDestroyEx(pLastCols, tsdbCacheFreeSLastColItem);
|
||||||
} else if (HASTYPE(pr->type, CACHESCAN_RETRIEVE_TYPE_ALL)) {
|
} 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;
|
tb_uid_t uid = pTableList[i].uid;
|
||||||
|
|
||||||
if ((code = tsdbCacheGetBatch(pr->pTsdb, uid, pRow, pr, ltype)) != 0) {
|
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;
|
++pr->tableIndex;
|
||||||
if (pResBlock->info.rows >= pResBlock->info.capacity) {
|
if (pResBlock->info.rows >= pResBlock->info.capacity) {
|
||||||
goto _end;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pGotAll && i == pr->numOfTables) {
|
||||||
|
*pGotAll = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
code = TSDB_CODE_INVALID_PARA;
|
code = TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ typedef struct SCacheRowsScanInfo {
|
||||||
SArray* pFuncTypeList;
|
SArray* pFuncTypeList;
|
||||||
int32_t numOfPks;
|
int32_t numOfPks;
|
||||||
SColumnInfo pkCol;
|
SColumnInfo pkCol;
|
||||||
|
bool gotAll;
|
||||||
} SCacheRowsScanInfo;
|
} SCacheRowsScanInfo;
|
||||||
|
|
||||||
static int32_t doScanCacheNext(SOperatorInfo* pOperator, SSDataBlock** ppRes);
|
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);
|
T_LONG_JMP(pTaskInfo->env, pTaskInfo->code);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pInfo->indexOfBufferedRes >= pBufRes->info.rows) {
|
if (pInfo->indexOfBufferedRes >= pBufRes->info.rows && !pInfo->gotAll) {
|
||||||
blockDataCleanup(pBufRes);
|
blockDataCleanup(pBufRes);
|
||||||
taosArrayClear(pInfo->pUidList);
|
taosArrayClear(pInfo->pUidList);
|
||||||
|
|
||||||
code =
|
code = pReaderFn->retrieveRows(pInfo->pLastrowReader, pBufRes, pInfo->pSlotIds, pInfo->pDstSlotIds,
|
||||||
pReaderFn->retrieveRows(pInfo->pLastrowReader, pBufRes, pInfo->pSlotIds, pInfo->pDstSlotIds, pInfo->pUidList);
|
pInfo->pUidList, &pInfo->gotAll);
|
||||||
QUERY_CHECK_CODE(code, lino, _end);
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
// check for tag values
|
// check for tag values
|
||||||
|
@ -394,7 +395,7 @@ static int32_t doScanCacheNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) {
|
||||||
taosArrayClear(pInfo->pUidList);
|
taosArrayClear(pInfo->pUidList);
|
||||||
|
|
||||||
code = pReaderFn->retrieveRows(pInfo->pLastrowReader, pInfo->pRes, pInfo->pSlotIds, pInfo->pDstSlotIds,
|
code = pReaderFn->retrieveRows(pInfo->pLastrowReader, pInfo->pRes, pInfo->pSlotIds, pInfo->pDstSlotIds,
|
||||||
pInfo->pUidList);
|
pInfo->pUidList, NULL);
|
||||||
QUERY_CHECK_CODE(code, lino, _end);
|
QUERY_CHECK_CODE(code, lino, _end);
|
||||||
|
|
||||||
pInfo->currentGroupIndex += 1;
|
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) {
|
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;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
SStbJoinTableList* pNew = taosMemoryMalloc(sizeof(SStbJoinTableList));
|
SStbJoinTableList* pNew = taosMemoryCalloc(1, sizeof(SStbJoinTableList));
|
||||||
if (NULL == pNew) {
|
if (NULL == pNew) {
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1037,16 +1037,13 @@ static int32_t getCacheBlkFromDownstreamOperator(struct SOperatorInfo* pOperator
|
||||||
SGroupCacheOperatorInfo* pGCache = pOperator->info;
|
SGroupCacheOperatorInfo* pGCache = pOperator->info;
|
||||||
|
|
||||||
while (continueFetch && TSDB_CODE_SUCCESS == code) {
|
while (continueFetch && TSDB_CODE_SUCCESS == code) {
|
||||||
int32_t code = getBlkFromDownstreamOperator(pOperator, pSession->downstreamIdx, ppRes);
|
QRY_ERR_RET(getBlkFromDownstreamOperator(pOperator, pSession->downstreamIdx, ppRes));
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NULL == *ppRes) {
|
if (NULL == *ppRes) {
|
||||||
code = handleDownstreamFetchDone(pOperator, pSession);
|
QRY_ERR_RET(handleDownstreamFetchDone(pOperator, pSession));
|
||||||
break;
|
break;
|
||||||
} else {
|
} 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) {
|
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;
|
SGroupCacheOperatorInfo* pGCache = pOperator->info;
|
||||||
SGroupCacheData* pGroup = pSession->pGroupData;
|
SGroupCacheData* pGroup = pSession->pGroupData;
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
@ -1181,6 +1183,7 @@ _return:
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1206,6 +1209,10 @@ static int32_t getBlkFromSessionCache(struct SOperatorInfo* pOperator, int64_t s
|
||||||
|
|
||||||
code = getCacheBlkFromDownstreamOperator(pOperator, pCtx, sessionId, pSession, ppRes);
|
code = getCacheBlkFromDownstreamOperator(pOperator, pCtx, sessionId, pSession, ppRes);
|
||||||
goto _return;
|
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) {
|
if (locked) {
|
||||||
|
@ -1292,6 +1299,9 @@ static int32_t initGroupCacheSession(struct SOperatorInfo* pOperator, SOperatorP
|
||||||
qError("fail to get session %" PRId64 " from pSessions", pGcParam->sessionId);
|
qError("fail to get session %" PRId64 " from pSessions", pGcParam->sessionId);
|
||||||
QRY_ERR_RET(TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
|
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;
|
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) {
|
if (NULL == *ppRes) {
|
||||||
qDebug("session %" PRId64 " in downstream %d total got %" PRId64 " rows", pGcParam->sessionId, pCtx->id, pSession->resRows);
|
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));
|
code = taosHashRemove(pCtx->pSessions, &pGcParam->sessionId, sizeof(pGcParam->sessionId));
|
||||||
|
|
|
@ -4828,6 +4828,9 @@ int32_t histogramFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResul
|
||||||
pInfo->normalized = 0;
|
pInfo->normalized = 0;
|
||||||
|
|
||||||
char* binTypeStr = strndup(varDataVal(pCtx->param[1].param.pz), varDataLen(pCtx->param[1].param.pz));
|
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);
|
int8_t binType = getHistogramBinType(binTypeStr);
|
||||||
taosMemoryFree(binTypeStr);
|
taosMemoryFree(binTypeStr);
|
||||||
|
|
||||||
|
@ -4835,6 +4838,9 @@ int32_t histogramFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResul
|
||||||
return TSDB_CODE_FUNC_FUNTION_PARA_VALUE;
|
return TSDB_CODE_FUNC_FUNTION_PARA_VALUE;
|
||||||
}
|
}
|
||||||
char* binDesc = strndup(varDataVal(pCtx->param[2].param.pz), varDataLen(pCtx->param[2].param.pz));
|
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;
|
int64_t normalized = pCtx->param[3].param.i;
|
||||||
if (normalized != 0 && normalized != 1) {
|
if (normalized != 0 && normalized != 1) {
|
||||||
taosMemoryFree(binDesc);
|
taosMemoryFree(binDesc);
|
||||||
|
|
|
@ -43,6 +43,10 @@ int32_t tHistogramCreate(int32_t numOfEntries, SHistogramInfo** pHisto) {
|
||||||
#if !defined(USE_ARRAYLIST)
|
#if !defined(USE_ARRAYLIST)
|
||||||
pHisto->pList = SSkipListCreate(MAX_SKIP_LIST_LEVEL, TSDB_DATA_TYPE_DOUBLE, sizeof(double));
|
pHisto->pList = SSkipListCreate(MAX_SKIP_LIST_LEVEL, TSDB_DATA_TYPE_DOUBLE, sizeof(double));
|
||||||
SInsertSupporter* pss = taosMemoryMalloc(sizeof(SInsertSupporter));
|
SInsertSupporter* pss = taosMemoryMalloc(sizeof(SInsertSupporter));
|
||||||
|
if (NULL == pss) {
|
||||||
|
taosMemoryFree(*pHisto);
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
pss->numOfEntries = pHisto->maxEntries;
|
pss->numOfEntries = pHisto->maxEntries;
|
||||||
pss->pSkipList = pHisto->pList;
|
pss->pSkipList = pHisto->pList;
|
||||||
|
|
||||||
|
@ -119,6 +123,9 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
|
||||||
#else
|
#else
|
||||||
tSkipListKey key = tSkipListCreateKey(TSDB_DATA_TYPE_DOUBLE, &val, tDataTypes[TSDB_DATA_TYPE_DOUBLE].nSize);
|
tSkipListKey key = tSkipListCreateKey(TSDB_DATA_TYPE_DOUBLE, &val, tDataTypes[TSDB_DATA_TYPE_DOUBLE].nSize);
|
||||||
SHistBin* entry = taosMemoryCalloc(1, sizeof(SHistBin));
|
SHistBin* entry = taosMemoryCalloc(1, sizeof(SHistBin));
|
||||||
|
if (entry == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
entry->val = val;
|
entry->val = val;
|
||||||
|
|
||||||
tSkipListNode* pResNode = SSkipListPut((*pHisto)->pList, entry, &key, 0);
|
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;
|
int32_t totalCount = 0;
|
||||||
|
|
||||||
char *binTypeStr = strndup(varDataVal(pInput[1].columnData->pData), varDataLen(pInput[1].columnData->pData));
|
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);
|
int8_t binType = getHistogramBinType(binTypeStr);
|
||||||
taosMemoryFree(binTypeStr);
|
taosMemoryFree(binTypeStr);
|
||||||
|
|
||||||
char *binDesc = strndup(varDataVal(pInput[2].columnData->pData), varDataLen(pInput[2].columnData->pData));
|
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);
|
int64_t normalized = *(int64_t *)(pInput[3].columnData->pData);
|
||||||
|
|
||||||
int32_t type = GET_PARAM_TYPE(pInput);
|
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);
|
int32_t inputLen = varDataTLen(buf);
|
||||||
|
|
||||||
*out = taosMemoryCalloc(1, inputLen);
|
*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));
|
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(buf), varDataLen(buf), varDataVal(*out));
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
sclError("charset:%s to %s. val:%s convert ncharTobinary failed.", DEFAULT_UNICODE_ENCODEC, tsCharset,
|
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) {
|
if (code) {
|
||||||
stError("vgId:%d failed to open stream meta file cursor, not perform compatible check, code:%s", pMeta->vgId,
|
stError("vgId:%d failed to open stream meta file cursor, not perform compatible check, code:%s", pMeta->vgId,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
code = tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
if (code) {
|
|
||||||
stError("vgId:%d failed to close meta file cursor, code:%s", pMeta->vgId, tstrerror(code));
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,10 +219,7 @@ int32_t streamMetaCheckBackendCompatible(SStreamMeta* pMeta) {
|
||||||
|
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
code = tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
if (code != 0) {
|
|
||||||
stError("vgId:%d failed to close meta file cursor, code:%s", pMeta->vgId, tstrerror(code));
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -977,10 +970,7 @@ int64_t streamMetaGetLatestCheckpointId(SStreamMeta* pMeta) {
|
||||||
code = tdbTbcMoveToFirst(pCur);
|
code = tdbTbcMoveToFirst(pCur);
|
||||||
if (code) {
|
if (code) {
|
||||||
stError("failed to move stream meta file cursor, the latest checkpointId is 0, vgId:%d", pMeta->vgId);
|
stError("failed to move stream meta file cursor, the latest checkpointId is 0, vgId:%d", pMeta->vgId);
|
||||||
int32_t ret = tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
if (ret != 0) {
|
|
||||||
stError("vgId:%d failed to close meta file cursor, code:%s", pMeta->vgId, tstrerror(ret));
|
|
||||||
}
|
|
||||||
return checkpointId;
|
return checkpointId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1003,11 +993,7 @@ int64_t streamMetaGetLatestCheckpointId(SStreamMeta* pMeta) {
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
|
|
||||||
int32_t ret = tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
if (ret != 0) {
|
|
||||||
stError("vgId:%d failed to close meta file cursor, code:%s", pMeta->vgId, tstrerror(ret));
|
|
||||||
}
|
|
||||||
|
|
||||||
return checkpointId;
|
return checkpointId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1047,10 +1033,7 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) {
|
||||||
if (code) {
|
if (code) {
|
||||||
stError("vgId:%d failed to open stream meta cursor, code:%s, not load any stream tasks", vgId, tstrerror(terrno));
|
stError("vgId:%d failed to open stream meta cursor, code:%s, not load any stream tasks", vgId, tstrerror(terrno));
|
||||||
taosArrayDestroy(pRecycleList);
|
taosArrayDestroy(pRecycleList);
|
||||||
int32_t ret = tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
if (ret != 0) {
|
|
||||||
stError("vgId:%d failed to close meta file cursor, code:%s", pMeta->vgId, tstrerror(ret));
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1137,9 +1120,7 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) {
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
|
|
||||||
if (tdbTbcClose(pCur) < 0) {
|
tdbTbcClose(pCur);
|
||||||
stError("vgId:%d failed to close meta-file cursor, code:%s, continue", vgId, tstrerror(terrno));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (taosArrayGetSize(pRecycleList) > 0) {
|
if (taosArrayGetSize(pRecycleList) > 0) {
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pRecycleList); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pRecycleList); ++i) {
|
||||||
|
|
|
@ -60,7 +60,7 @@ int32_t tdbTbTraversal(TTB *pTb, void *data,
|
||||||
|
|
||||||
// TBC
|
// TBC
|
||||||
int32_t tdbTbcOpen(TTB *pTb, TBC **ppTbc, TXN *pTxn);
|
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 tdbTbcIsValid(TBC *pTbc);
|
||||||
int32_t tdbTbcMoveTo(TBC *pTbc, const void *pKey, int kLen, int *c);
|
int32_t tdbTbcMoveTo(TBC *pTbc, const void *pKey, int kLen, int *c);
|
||||||
int32_t tdbTbcMoveToFirst(TBC *pTbc);
|
int32_t tdbTbcMoveToFirst(TBC *pTbc);
|
||||||
|
|
|
@ -172,12 +172,11 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPg
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbBtreeClose(SBTree *pBt) {
|
void tdbBtreeClose(SBTree *pBt) {
|
||||||
if (pBt) {
|
if (pBt) {
|
||||||
tdbFree(pBt->pBuf);
|
tdbFree(pBt->pBuf);
|
||||||
tdbOsFree(pBt);
|
tdbOsFree(pBt);
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, int vLen, TXN *pTxn) {
|
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
|
// move to the position to insert
|
||||||
ret = tdbBtcMoveTo(&btc, pKey, kLen, &c);
|
ret = tdbBtcMoveTo(&btc, pKey, kLen, &c);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
tdbError("tdb/btree-insert: btc move to failed with ret: %d.", ret);
|
tdbError("tdb/btree-insert: btc move to failed with ret: %d.", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -213,7 +212,7 @@ int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, in
|
||||||
btc.idx++;
|
btc.idx++;
|
||||||
} else if (c == 0) {
|
} else if (c == 0) {
|
||||||
// dup key not allowed with insert
|
// 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);
|
tdbError("tdb/btree-insert: dup key. pKey: %p, kLen: %d, btc: %p, pTxn: %p", pKey, kLen, &btc, pTxn);
|
||||||
return TSDB_CODE_DUP_KEY;
|
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);
|
ret = tdbBtcUpsert(&btc, pKey, kLen, pVal, vLen, 1);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
tdbError("tdb/btree-insert: btc upsert failed with ret: %d.", ret);
|
tdbError("tdb/btree-insert: btc upsert failed with ret: %d.", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,20 +249,20 @@ int tdbBtreeDelete(SBTree *pBt, const void *pKey, int kLen, TXN *pTxn) {
|
||||||
// move the cursor
|
// move the cursor
|
||||||
ret = tdbBtcMoveTo(&btc, pKey, kLen, &c);
|
ret = tdbBtcMoveTo(&btc, pKey, kLen, &c);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
tdbError("tdb/btree-delete: btc move to failed with ret: %d.", ret);
|
tdbError("tdb/btree-delete: btc move to failed with ret: %d.", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (btc.idx < 0 || c != 0) {
|
if (btc.idx < 0 || c != 0) {
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
return TSDB_CODE_NOT_FOUND;
|
return TSDB_CODE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete the key
|
// delete the key
|
||||||
ret = tdbBtcDelete(&btc);
|
ret = tdbBtcDelete(&btc);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -278,7 +277,7 @@ int tdbBtreeDelete(SBTree *pBt, const void *pKey, int kLen, TXN *pTxn) {
|
||||||
btc.coder.ofps = NULL;
|
btc.coder.ofps = NULL;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
return 0;
|
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);
|
ret = tdbBtcMoveTo(&btc, pKey, kLen, &cret);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
tdbError("tdb/btree-pget: btc move to failed with ret: %d.", ret);
|
tdbError("tdb/btree-pget: btc move to failed with ret: %d.", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (btc.idx < 0 || cret) {
|
if (btc.idx < 0 || cret) {
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
return TSDB_CODE_NOT_FOUND;
|
return TSDB_CODE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
pCell = tdbPageGetCell(btc.pPage, btc.idx);
|
pCell = tdbPageGetCell(btc.pPage, btc.idx);
|
||||||
ret = tdbBtreeDecodeCell(btc.pPage, pCell, &cd, btc.pTxn, pBt);
|
ret = tdbBtreeDecodeCell(btc.pPage, pCell, &cd, btc.pTxn, pBt);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
tdbError("tdb/btree-pget: decode cell failed with ret: %d.", ret);
|
tdbError("tdb/btree-pget: decode cell failed with ret: %d.", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -372,7 +371,7 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL
|
||||||
if (ppKey) {
|
if (ppKey) {
|
||||||
pTKey = tdbRealloc(*ppKey, cd.kLen);
|
pTKey = tdbRealloc(*ppKey, cd.kLen);
|
||||||
if (pTKey == NULL) {
|
if (pTKey == NULL) {
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
tdbError("tdb/btree-pget: realloc pTKey failed.");
|
tdbError("tdb/btree-pget: realloc pTKey failed.");
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
@ -384,7 +383,7 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL
|
||||||
if (ppVal) {
|
if (ppVal) {
|
||||||
pTVal = tdbRealloc(*ppVal, cd.vLen);
|
pTVal = tdbRealloc(*ppVal, cd.vLen);
|
||||||
if (pTVal == NULL) {
|
if (pTVal == NULL) {
|
||||||
(void)tdbBtcClose(&btc);
|
tdbBtcClose(&btc);
|
||||||
tdbError("tdb/btree-pget: realloc pTVal failed.");
|
tdbError("tdb/btree-pget: realloc pTVal failed.");
|
||||||
return terrno;
|
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);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -606,7 +605,11 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
||||||
if (i < nOlds - 1) {
|
if (i < nOlds - 1) {
|
||||||
((SPgno *)pDivCell[i])[0] = ((SIntHdr *)pOlds[i]->pData)->pgno;
|
((SPgno *)pDivCell[i])[0] = ((SIntHdr *)pOlds[i]->pData)->pgno;
|
||||||
((SIntHdr *)pOlds[i]->pData)->pgno = 0;
|
((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;
|
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.pBt = pBt;
|
||||||
iarg.flags = TDB_BTREE_PAGE_GET_FLAGS(pOlds[0]);
|
iarg.flags = TDB_BTREE_PAGE_GET_FLAGS(pOlds[0]);
|
||||||
for (int i = 0; i < nOlds; i++) {
|
for (int i = 0; i < nOlds; i++) {
|
||||||
(void)tdbPageCreate(pOlds[0]->pageSize, &pOldsCopy[i], tdbDefaultMalloc, NULL);
|
ret = tdbPageCreate(pOlds[0]->pageSize, &pOldsCopy[i], tdbDefaultMalloc, NULL);
|
||||||
(void)tdbBtreeInitPage(pOldsCopy[i], &iarg, 0);
|
if (ret < 0) {
|
||||||
(void)tdbPageCopy(pOlds[i], pOldsCopy[i], 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;
|
pOlds[i]->nOverflow = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
iNew = 0;
|
iNew = 0;
|
||||||
nNewCells = 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++) {
|
for (int iOld = 0; iOld < nOlds; iOld++) {
|
||||||
SPage *pPage;
|
SPage *pPage;
|
||||||
|
@ -820,7 +839,11 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nNewCells < infoNews[iNew].cnt) {
|
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++;
|
nNewCells++;
|
||||||
|
|
||||||
// insert parent page
|
// insert parent page
|
||||||
|
@ -842,7 +865,11 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
||||||
pgno = TDB_PAGE_PGNO(pNews[iNew]);
|
pgno = TDB_PAGE_PGNO(pNews[iNew]);
|
||||||
(void)tdbBtreeEncodeCell(pParent, cd.pKey, cd.kLen, (void *)&pgno, sizeof(SPgno), pNewCell, &szNewCell,
|
(void)tdbBtreeEncodeCell(pParent, cd.pKey, cd.kLen, (void *)&pgno, sizeof(SPgno), pNewCell, &szNewCell,
|
||||||
pTxn, pBt);
|
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);
|
tdbOsFree(pNewCell);
|
||||||
|
|
||||||
if (TDB_CELLDECODER_FREE_VAL(&cd)) {
|
if (TDB_CELLDECODER_FREE_VAL(&cd)) {
|
||||||
|
@ -855,7 +882,11 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
||||||
iNew++;
|
iNew++;
|
||||||
nNewCells = 0;
|
nNewCells = 0;
|
||||||
if (iNew < nNews) {
|
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 {
|
} else {
|
||||||
|
@ -874,13 +905,21 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
((SPgno *)pCell)[0] = TDB_PAGE_PGNO(pNews[iNew]);
|
((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
|
// move to next new page
|
||||||
iNew++;
|
iNew++;
|
||||||
nNewCells = 0;
|
nNewCells = 0;
|
||||||
if (iNew < nNews) {
|
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]);
|
pIntHdr->pgno = TDB_PAGE_PGNO(pNews[nNews - 1]);
|
||||||
} else {
|
} else {
|
||||||
((SPgno *)pDivCell[nOlds - 1])[0] = TDB_PAGE_PGNO(pNews[nNews - 1]);
|
((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++) {
|
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) {
|
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]);
|
i8 flags = TDB_BTREE_ROOT | TDB_BTREE_PAGE_IS_LEAF(pNews[0]);
|
||||||
// copy content to the parent page
|
// copy content to the parent page
|
||||||
(void)tdbBtreeInitPage(pParent, &(SBtreeInitPageArg){.flags = flags, .pBt = pBt}, 0);
|
ret = tdbBtreeInitPage(pParent, &(SBtreeInitPageArg){.flags = flags, .pBt = pBt}, 0);
|
||||||
(void)tdbPageCopy(pNews[0], pParent, 1);
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
ret = tdbPageCopy(pNews[0], pParent, 1);
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
if (!TDB_BTREE_PAGE_IS_LEAF(pNews[0])) {
|
if (!TDB_BTREE_PAGE_IS_LEAF(pNews[0])) {
|
||||||
((SIntHdr *)(pParent->pData))->pgno = ((SIntHdr *)(pNews[0]->pData))->pgno;
|
((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++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
|
@ -1991,7 +2043,11 @@ int tdbBtcMoveToNext(SBTC *pBtc) {
|
||||||
return 0;
|
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++;
|
pBtc->idx++;
|
||||||
|
|
||||||
if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) {
|
if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) {
|
||||||
|
@ -2020,6 +2076,7 @@ int tdbBtcMoveToNext(SBTC *pBtc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbBtcMoveToPrev(SBTC *pBtc) {
|
int tdbBtcMoveToPrev(SBTC *pBtc) {
|
||||||
|
int32_t ret = 0;
|
||||||
if (pBtc->idx < 0) return TSDB_CODE_FAILED;
|
if (pBtc->idx < 0) return TSDB_CODE_FAILED;
|
||||||
|
|
||||||
pBtc->idx--;
|
pBtc->idx--;
|
||||||
|
@ -2034,7 +2091,11 @@ int tdbBtcMoveToPrev(SBTC *pBtc) {
|
||||||
return 0;
|
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--;
|
pBtc->idx--;
|
||||||
if (pBtc->idx >= 0) {
|
if (pBtc->idx >= 0) {
|
||||||
break;
|
break;
|
||||||
|
@ -2045,7 +2106,11 @@ int tdbBtcMoveToPrev(SBTC *pBtc) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) break;
|
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)) {
|
if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) {
|
||||||
pBtc->idx = TDB_PAGE_TOTAL_CELLS(pBtc->pPage) - 1;
|
pBtc->idx = TDB_PAGE_TOTAL_CELLS(pBtc->pPage) - 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2167,6 +2232,9 @@ int tdbBtcDelete(SBTC *pBtc) {
|
||||||
bool destroyOfps = false;
|
bool destroyOfps = false;
|
||||||
if (!pBtc->pPage->pPager->ofps) {
|
if (!pBtc->pPage->pPager->ofps) {
|
||||||
pBtc->pPage->pPager->ofps = taosArrayInit(8, sizeof(SPage *));
|
pBtc->pPage->pPager->ofps = taosArrayInit(8, sizeof(SPage *));
|
||||||
|
if (pBtc->pPage->pPager->ofps == NULL) {
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
destroyOfps = true;
|
destroyOfps = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2189,7 +2257,11 @@ int tdbBtcDelete(SBTC *pBtc) {
|
||||||
if (idx == nCells - 1) {
|
if (idx == nCells - 1) {
|
||||||
if (idx) {
|
if (idx) {
|
||||||
pBtc->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
|
// loop to update the interial page
|
||||||
pgno = TDB_PAGE_PGNO(pBtc->pPage);
|
pgno = TDB_PAGE_PGNO(pBtc->pPage);
|
||||||
|
@ -2440,7 +2512,11 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
|
||||||
|
|
||||||
// compare first cell
|
// compare first cell
|
||||||
pBtc->idx = lidx;
|
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);
|
c = pBt->kcmpr(pKey, kLen, pTKey, tkLen);
|
||||||
if (c <= 0) {
|
if (c <= 0) {
|
||||||
ridx = lidx - 1;
|
ridx = lidx - 1;
|
||||||
|
@ -2450,7 +2526,11 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
|
||||||
// compare last cell
|
// compare last cell
|
||||||
if (lidx <= ridx) {
|
if (lidx <= ridx) {
|
||||||
pBtc->idx = 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);
|
c = pBt->kcmpr(pKey, kLen, pTKey, tkLen);
|
||||||
if (c >= 0) {
|
if (c >= 0) {
|
||||||
lidx = ridx + 1;
|
lidx = ridx + 1;
|
||||||
|
@ -2465,7 +2545,11 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
|
||||||
if (lidx > ridx) break;
|
if (lidx > ridx) break;
|
||||||
|
|
||||||
pBtc->idx = (lidx + ridx) >> 1;
|
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);
|
c = pBt->kcmpr(pKey, kLen, pTKey, tkLen);
|
||||||
if (c < 0) {
|
if (c < 0) {
|
||||||
// pKey < cd.pKey
|
// pKey < cd.pKey
|
||||||
|
@ -2499,18 +2583,18 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbBtcClose(SBTC *pBtc) {
|
void tdbBtcClose(SBTC *pBtc) {
|
||||||
if (pBtc->iPage < 0) {
|
if (pBtc->iPage < 0) {
|
||||||
if (pBtc->freeTxn) {
|
if (pBtc->freeTxn) {
|
||||||
tdbTxnClose(pBtc->pTxn);
|
tdbTxnClose(pBtc->pTxn);
|
||||||
}
|
}
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (NULL == pBtc->pPage) {
|
if (NULL == pBtc->pPage) {
|
||||||
tdbError("tdb/btc-close: null ptr pPage.");
|
tdbError("tdb/btc-close: null ptr pPage.");
|
||||||
return TSDB_CODE_FAILED;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tdbPagerReturnPage(pBtc->pBt->pPager, pBtc->pPage, pBtc->pTxn);
|
tdbPagerReturnPage(pBtc->pBt->pPager, pBtc->pPage, pBtc->pTxn);
|
||||||
|
@ -2536,7 +2620,7 @@ int tdbBtcClose(SBTC *pBtc) {
|
||||||
tdbTxnClose(pBtc->pTxn);
|
tdbTxnClose(pBtc->pTxn);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbBtcIsValid(SBTC *pBtc) {
|
int tdbBtcIsValid(SBTC *pBtc) {
|
||||||
|
|
|
@ -149,7 +149,7 @@ static int tdbPCacheAlterImpl(SPCache *pCache, int32_t nPage) {
|
||||||
SPage *pPage = *ppPage;
|
SPage *pPage = *ppPage;
|
||||||
*ppPage = pPage->pFreeNext;
|
*ppPage = pPage->pFreeNext;
|
||||||
pCache->aPage[pPage->id] = NULL;
|
pCache->aPage[pPage->id] = NULL;
|
||||||
(void)tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
||||||
pCache->nFree--;
|
pCache->nFree--;
|
||||||
} else {
|
} else {
|
||||||
ppPage = &(*ppPage)->pFreeNext;
|
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));
|
tdbTrace("pcache/free2 page: %p/%d, pgno:%d, ", pPage, pPage->id, TDB_PAGE_PGNO(pPage));
|
||||||
|
|
||||||
tdbPCacheRemovePageFromHash(pCache, 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);
|
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);
|
tdbTrace("pcache destroy page: %p/%d/%d", pPage, TDB_PAGE_PGNO(pPage), pPage->id);
|
||||||
|
|
||||||
tdbPCacheRemovePageFromHash(pCache, pPage);
|
tdbPCacheRemovePageFromHash(pCache, pPage);
|
||||||
(void)tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,14 +518,14 @@ static int tdbPCacheCloseImpl(SPCache *pCache) {
|
||||||
// free free page
|
// free free page
|
||||||
for (SPage *pPage = pCache->pFree; pPage;) {
|
for (SPage *pPage = pCache->pFree; pPage;) {
|
||||||
SPage *pPageT = pPage->pFreeNext;
|
SPage *pPageT = pPage->pFreeNext;
|
||||||
(void)tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
||||||
pPage = pPageT;
|
pPage = pPageT;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t iBucket = 0; iBucket < pCache->nHash; iBucket++) {
|
for (int32_t iBucket = 0; iBucket < pCache->nHash; iBucket++) {
|
||||||
for (SPage *pPage = pCache->pgHash[iBucket]; pPage;) {
|
for (SPage *pPage = pCache->pgHash[iBucket]; pPage;) {
|
||||||
SPage *pPageT = pPage->pHashNext;
|
SPage *pPageT = pPage->pHashNext;
|
||||||
(void)tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
tdbPageDestroy(pPage, tdbDefaultFree, NULL);
|
||||||
pPage = pPageT;
|
pPage = pPageT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,19 +79,19 @@ int tdbPageCreate(int pageSize, SPage **ppPage, void *(*xMalloc)(void *, size_t)
|
||||||
return 0;
|
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;
|
u8 *ptr;
|
||||||
|
|
||||||
tdbTrace("tdb/page-destroy: %p/%d %p", pPage, pPage->id, xFree);
|
tdbTrace("tdb/page-destroy: %p/%d %p", pPage, pPage->id, xFree);
|
||||||
|
|
||||||
if (pPage->isDirty) {
|
if (pPage->isDirty) {
|
||||||
tdbError("tdb/page-destroy: dirty page: %" PRIu8 ".", pPage->isDirty);
|
tdbError("tdb/page-destroy: dirty page: %" PRIu8 ".", pPage->isDirty);
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xFree) {
|
if (!xFree) {
|
||||||
tdbError("tdb/page-destroy: null xFree.");
|
tdbError("tdb/page-destroy: null xFree.");
|
||||||
return TSDB_CODE_INVALID_PARA;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int iOvfl = 0; iOvfl < pPage->nOverflow; iOvfl++) {
|
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;
|
ptr = pPage->pData;
|
||||||
xFree(arg, ptr);
|
xFree(arg, ptr);
|
||||||
|
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tdbPageZero(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell *, int, TXN *, SBTree *pBt)) {
|
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 iOvfl;
|
||||||
int lidx; // local idx
|
int lidx; // local idx
|
||||||
SCell *pNewCell;
|
SCell *pNewCell;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (szCell > TDB_PAGE_MAX_FREE_BLOCK(pPage, pPage->pPageHdr - pPage->pData)) {
|
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,
|
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++;
|
iOvfl++;
|
||||||
} else {
|
} else {
|
||||||
// page must has enough space to hold the cell locally
|
// 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);
|
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) {
|
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);
|
return tdbPageInsertCell(pPage, idx, pCell, szCell, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,6 +241,7 @@ int tdbPageDropCell(SPage *pPage, int idx, TXN *pTxn, SBTree *pBt) {
|
||||||
int szCell;
|
int szCell;
|
||||||
int nCells;
|
int nCells;
|
||||||
int iOvfl;
|
int iOvfl;
|
||||||
|
int ret;
|
||||||
|
|
||||||
nCells = TDB_PAGE_NCELLS(pPage);
|
nCells = TDB_PAGE_NCELLS(pPage);
|
||||||
|
|
||||||
|
@ -263,9 +271,12 @@ int tdbPageDropCell(SPage *pPage, int idx, TXN *pTxn, SBTree *pBt) {
|
||||||
lidx = idx - iOvfl;
|
lidx = idx - iOvfl;
|
||||||
pCell = TDB_PAGE_CELL_AT(pPage, lidx);
|
pCell = TDB_PAGE_CELL_AT(pPage, lidx);
|
||||||
szCell = (*pPage->xCellSize)(pPage, pCell, 1, pTxn, pBt);
|
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);
|
TDB_PAGE_NCELLS_SET(pPage, nCells - 1);
|
||||||
|
|
||||||
for (; iOvfl < pPage->nOverflow; iOvfl++) {
|
for (; iOvfl < pPage->nOverflow; iOvfl++) {
|
||||||
pPage->aiOvfl[iOvfl]--;
|
pPage->aiOvfl[iOvfl]--;
|
||||||
if (pPage->aiOvfl[iOvfl] <= 0) {
|
if (pPage->aiOvfl[iOvfl] <= 0) {
|
||||||
|
|
|
@ -802,7 +802,7 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) {
|
||||||
code = tdbTbcMoveToFirst(pCur);
|
code = tdbTbcMoveToFirst(pCur);
|
||||||
if (code) {
|
if (code) {
|
||||||
tdbError("tdb/remove-free-page: moveto first failed with ret: %d.", code);
|
tdbError("tdb/remove-free-page: moveto first failed with ret: %d.", code);
|
||||||
(void)tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -812,7 +812,7 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) {
|
||||||
code = tdbTbcGet(pCur, (const void **)&pKey, &nKey, NULL, NULL);
|
code = tdbTbcGet(pCur, (const void **)&pKey, &nKey, NULL, NULL);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
// tdbError("tdb/remove-free-page: tbc get failed with ret: %d.", code);
|
// tdbError("tdb/remove-free-page: tbc get failed with ret: %d.", code);
|
||||||
(void)tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -823,10 +823,10 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) {
|
||||||
code = tdbTbcDelete(pCur);
|
code = tdbTbcDelete(pCur);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
tdbError("tdb/remove-free-page: tbc delete failed with ret: %d.", code);
|
tdbError("tdb/remove-free-page: tbc delete failed with ret: %d.", code);
|
||||||
(void)tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
(void)tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1165,14 +1165,14 @@ int tdbPagerRestoreJournals(SPager *pPager) {
|
||||||
code = tdbPagerRestore(pPager, jname);
|
code = tdbPagerRestore(pPager, jname);
|
||||||
if (code) {
|
if (code) {
|
||||||
taosArrayDestroy(pTxnList);
|
taosArrayDestroy(pTxnList);
|
||||||
(void)tdbCloseDir(&pDir);
|
tdbCloseDir(&pDir);
|
||||||
tdbError("failed to restore file due to %s. jFileName:%s", tstrerror(code), jname);
|
tdbError("failed to restore file due to %s. jFileName:%s", tstrerror(code), jname);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pTxnList);
|
taosArrayDestroy(pTxnList);
|
||||||
(void)tdbCloseDir(&pDir);
|
tdbCloseDir(&pDir);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1195,7 +1195,7 @@ int tdbPagerRollback(SPager *pPager) {
|
||||||
jname[dirLen] = '/';
|
jname[dirLen] = '/';
|
||||||
memcpy(jname + dirLen + 1, name, strlen(name));
|
memcpy(jname + dirLen + 1, name, strlen(name));
|
||||||
if (tdbOsRemove(jname) < 0 && errno != ENOENT) {
|
if (tdbOsRemove(jname) < 0 && errno != ENOENT) {
|
||||||
(void)tdbCloseDir(&pDir);
|
tdbCloseDir(&pDir);
|
||||||
|
|
||||||
tdbError("failed to remove file due to %s. jFileName:%s", strerror(errno), name);
|
tdbError("failed to remove file due to %s. jFileName:%s", strerror(errno), name);
|
||||||
return terrno = TAOS_SYSTEM_ERROR(errno);
|
return terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
@ -1203,7 +1203,7 @@ int tdbPagerRollback(SPager *pPager) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)tdbCloseDir(&pDir);
|
tdbCloseDir(&pDir);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF
|
||||||
|
|
||||||
int tdbTbClose(TTB *pTb) {
|
int tdbTbClose(TTB *pTb) {
|
||||||
if (pTb) {
|
if (pTb) {
|
||||||
(void)tdbBtreeClose(pTb->pBt);
|
tdbBtreeClose(pTb->pBt);
|
||||||
tdbOsFree(pTb);
|
tdbOsFree(pTb);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -260,7 +260,7 @@ int32_t tdbTbTraversal(TTB *pTb, void *data,
|
||||||
}
|
}
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pValue);
|
tdbFree(pValue);
|
||||||
(void)tdbTbcClose(pCur);
|
tdbTbcClose(pCur);
|
||||||
|
|
||||||
return 0;
|
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);
|
return tdbBtcUpsert(&pTbc->btc, pKey, nKey, pData, nData, insert);
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbTbcClose(TBC *pTbc) {
|
void tdbTbcClose(TBC *pTbc) {
|
||||||
if (pTbc) {
|
if (pTbc) {
|
||||||
(void)tdbBtcClose(&pTbc->btc);
|
tdbBtcClose(&pTbc->btc);
|
||||||
tdbOsFree(pTbc);
|
tdbOsFree(pTbc);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbTbcIsValid(TBC *pTbc) { return tdbBtcIsValid(&pTbc->btc); }
|
int tdbTbcIsValid(TBC *pTbc) { return tdbBtcIsValid(&pTbc->btc); }
|
||||||
|
|
|
@ -27,17 +27,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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 int8_t i8;
|
||||||
typedef int16_t i16;
|
typedef int16_t i16;
|
||||||
typedef int32_t i32;
|
typedef int32_t i32;
|
||||||
|
@ -156,11 +145,11 @@ struct SBTC {
|
||||||
};
|
};
|
||||||
|
|
||||||
// SBTree
|
// SBTree
|
||||||
int tdbBtreeOpen(int keyLen, int valLen, SPager *pFile, char const *tbname, SPgno pgno, tdb_cmpr_fn_t kcmpr, TDB *pEnv,
|
int tdbBtreeOpen(int keyLen, int valLen, SPager *pFile, char const *tbname, SPgno pgno, tdb_cmpr_fn_t kcmpr, TDB *pEnv,
|
||||||
SBTree **ppBt);
|
SBTree **ppBt);
|
||||||
int tdbBtreeClose(SBTree *pBt);
|
void tdbBtreeClose(SBTree *pBt);
|
||||||
int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, int vLen, TXN *pTxn);
|
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 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 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 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);
|
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);
|
int tdbBtreeInitPage(SPage *pPage, void *arg, int init);
|
||||||
|
|
||||||
// SBTC
|
// SBTC
|
||||||
int tdbBtcOpen(SBTC *pBtc, SBTree *pBt, TXN *pTxn);
|
int tdbBtcOpen(SBTC *pBtc, SBTree *pBt, TXN *pTxn);
|
||||||
int tdbBtcClose(SBTC *pBtc);
|
void tdbBtcClose(SBTC *pBtc);
|
||||||
int tdbBtcIsValid(SBTC *pBtc);
|
int tdbBtcIsValid(SBTC *pBtc);
|
||||||
int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst);
|
int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst);
|
||||||
int tdbBtcMoveToFirst(SBTC *pBtc);
|
int tdbBtcMoveToFirst(SBTC *pBtc);
|
||||||
int tdbBtcMoveToLast(SBTC *pBtc);
|
int tdbBtcMoveToLast(SBTC *pBtc);
|
||||||
int tdbBtcMoveToNext(SBTC *pBtc);
|
int tdbBtcMoveToNext(SBTC *pBtc);
|
||||||
int tdbBtcMoveToPrev(SBTC *pBtc);
|
int tdbBtcMoveToPrev(SBTC *pBtc);
|
||||||
int tdbBtreeNext(SBTC *pBtc, void **ppKey, int *kLen, void **ppVal, int *vLen);
|
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 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 tdbBtcGet(SBTC *pBtc, const void **ppKey, int *kLen, const void **ppVal, int *vLen);
|
||||||
int tdbBtcDelete(SBTC *pBtc);
|
int tdbBtcDelete(SBTC *pBtc);
|
||||||
int tdbBtcUpsert(SBTC *pBtc, const void *pKey, int kLen, const void *pData, int nData, int insert);
|
int tdbBtcUpsert(SBTC *pBtc, const void *pKey, int kLen, const void *pData, int nData, int insert);
|
||||||
|
|
||||||
// tdbPager.c ====================================
|
// tdbPager.c ====================================
|
||||||
|
|
||||||
|
@ -339,7 +328,7 @@ static inline int tdbTryLockPage(tdb_spinlock_t *pLock) {
|
||||||
#define TDB_PAGE_OFFSET_SIZE(pPage) ((pPage)->pPageMethods->szOffset)
|
#define TDB_PAGE_OFFSET_SIZE(pPage) ((pPage)->pPageMethods->szOffset)
|
||||||
|
|
||||||
int tdbPageCreate(int pageSize, SPage **ppPage, void *(*xMalloc)(void *, size_t), void *arg);
|
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 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));
|
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);
|
int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl);
|
||||||
|
|
|
@ -27,6 +27,17 @@ extern "C" {
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "thash.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 -----------------
|
// For memory -----------------
|
||||||
#define tdbOsMalloc taosMemoryMalloc
|
#define tdbOsMalloc taosMemoryMalloc
|
||||||
#define tdbOsCalloc taosMemoryCalloc
|
#define tdbOsCalloc taosMemoryCalloc
|
||||||
|
@ -59,9 +70,16 @@ typedef TdFilePtr tdb_fd_t;
|
||||||
#define tdbReadDir taosReadDir
|
#define tdbReadDir taosReadDir
|
||||||
#define tdbGetDirEntryName taosGetDirEntryName
|
#define tdbGetDirEntryName taosGetDirEntryName
|
||||||
#define tdbDirEntryBaseName taosDirEntryBaseName
|
#define tdbDirEntryBaseName taosDirEntryBaseName
|
||||||
#define tdbCloseDir taosCloseDir
|
|
||||||
#define tdbOsRemove remove
|
static FORCE_INLINE void tdbCloseDir(TdDirPtr *ppDir) {
|
||||||
#define tdbOsFileSize(FD, PSIZE) taosFStatFile(FD, PSIZE, NULL)
|
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 */
|
/* directory */
|
||||||
#define tdbOsMkdir taosMkDir
|
#define tdbOsMkdir taosMkDir
|
||||||
|
|
Loading…
Reference in New Issue