enh: add keep option while show stable. (#30294)
This commit is contained in:
parent
a03143147f
commit
0b8bff92c6
|
@ -1430,6 +1430,7 @@ typedef struct {
|
||||||
int64_t watermark1;
|
int64_t watermark1;
|
||||||
int64_t watermark2;
|
int64_t watermark2;
|
||||||
int32_t ttl;
|
int32_t ttl;
|
||||||
|
int32_t keep;
|
||||||
SArray* pFuncs;
|
SArray* pFuncs;
|
||||||
int32_t commentLen;
|
int32_t commentLen;
|
||||||
char* pComment;
|
char* pComment;
|
||||||
|
|
|
@ -3970,6 +3970,8 @@ int32_t tSerializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pRsp->keep));
|
||||||
|
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
@ -4070,6 +4072,13 @@ int32_t tDeserializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp)
|
||||||
pRsp->pColRefs = NULL;
|
pRsp->pColRefs = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!tDecodeIsEnd(&decoder)) {
|
||||||
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pRsp->keep));
|
||||||
|
} else {
|
||||||
|
pRsp->keep = 0;
|
||||||
|
}
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
|
|
@ -2326,6 +2326,7 @@ static int32_t mndBuildStbCfgImp(SDbObj *pDb, SStbObj *pStb, const char *tbName,
|
||||||
pRsp->watermark1 = pStb->watermark[0];
|
pRsp->watermark1 = pStb->watermark[0];
|
||||||
pRsp->watermark2 = pStb->watermark[1];
|
pRsp->watermark2 = pStb->watermark[1];
|
||||||
pRsp->ttl = pStb->ttl;
|
pRsp->ttl = pStb->ttl;
|
||||||
|
pRsp->keep = pStb->keep;
|
||||||
pRsp->commentLen = pStb->commentLen;
|
pRsp->commentLen = pStb->commentLen;
|
||||||
if (pStb->commentLen > 0) {
|
if (pStb->commentLen > 0) {
|
||||||
pRsp->pComment = taosStrdup(pStb->comment);
|
pRsp->pComment = taosStrdup(pStb->comment);
|
||||||
|
|
|
@ -784,6 +784,11 @@ static void appendTableOptions(char* buf, int32_t* len, SDbCfgInfo* pDbCfg, STab
|
||||||
if (pCfg->ttl > 0) {
|
if (pCfg->ttl > 0) {
|
||||||
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||||
" TTL %d", pCfg->ttl);
|
" TTL %d", pCfg->ttl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pCfg->keep > 0) {
|
||||||
|
*len += tsnprintf(buf + VARSTR_HEADER_SIZE + *len, SHOW_CREATE_TB_RESULT_FIELD2_LEN - (VARSTR_HEADER_SIZE + *len),
|
||||||
|
" KEEP %dm", pCfg->keep);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_SUPER_TABLE == pCfg->tableType || TSDB_NORMAL_TABLE == pCfg->tableType) {
|
if (TSDB_SUPER_TABLE == pCfg->tableType || TSDB_NORMAL_TABLE == pCfg->tableType) {
|
||||||
|
|
|
@ -101,6 +101,16 @@ class TDTestCase(TBase):
|
||||||
tdSql.execute("CREATE TABLE ntb (ts TIMESTAMP, a INT, b FLOAT, c BINARY(10))")
|
tdSql.execute("CREATE TABLE ntb (ts TIMESTAMP, a INT, b FLOAT, c BINARY(10))")
|
||||||
tdSql.error("ALTER TABLE ntb keep 1d",expectErrInfo="only super table can alter keep duration")
|
tdSql.error("ALTER TABLE ntb keep 1d",expectErrInfo="only super table can alter keep duration")
|
||||||
|
|
||||||
|
def chceck_stb_keep_show_create(self):
|
||||||
|
tdLog.info(f"check stb keep show create")
|
||||||
|
tdSql.execute("USE test")
|
||||||
|
tdSql.execute("CREATE STABLE stb (ts TIMESTAMP, a INT, b FLOAT, c BINARY(10)) TAGS (e_id INT) KEEP 10d")
|
||||||
|
tdSql.query("SHOW CREATE TABLE stb")
|
||||||
|
tdSql.checkData(0, 1, "CREATE STABLE `stb` (`ts` TIMESTAMP ENCODE 'delta-i' COMPRESS 'lz4' LEVEL 'medium', `a` INT ENCODE 'simple8b' COMPRESS 'lz4' LEVEL 'medium', `b` FLOAT ENCODE 'delta-d' COMPRESS 'lz4' LEVEL 'medium', `c` VARCHAR(10) ENCODE 'disabled' COMPRESS 'zstd' LEVEL 'medium') TAGS (`e_id` INT) KEEP 14400m")
|
||||||
|
tdSql.execute("ALTER TABLE stb KEEP 5d")
|
||||||
|
tdSql.query("SHOW CREATE TABLE stb")
|
||||||
|
tdSql.checkData(0, 1, "CREATE STABLE `stb` (`ts` TIMESTAMP ENCODE 'delta-i' COMPRESS 'lz4' LEVEL 'medium', `a` INT ENCODE 'simple8b' COMPRESS 'lz4' LEVEL 'medium', `b` FLOAT ENCODE 'delta-d' COMPRESS 'lz4' LEVEL 'medium', `c` VARCHAR(10) ENCODE 'disabled' COMPRESS 'zstd' LEVEL 'medium') TAGS (`e_id` INT) KEEP 7200m")
|
||||||
|
|
||||||
# run
|
# run
|
||||||
def run(self):
|
def run(self):
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
@ -126,6 +136,9 @@ class TDTestCase(TBase):
|
||||||
# check normal table with keep
|
# check normal table with keep
|
||||||
self.check_normal_table_with_keep()
|
self.check_normal_table_with_keep()
|
||||||
|
|
||||||
|
# check stb keep show create
|
||||||
|
self.chceck_stb_keep_show_create()
|
||||||
|
|
||||||
tdLog.success(f"{__file__} successfully executed")
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
tdCases.addLinux(__file__, TDTestCase())
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
|
Loading…
Reference in New Issue