Skip to content
Open
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
49f65a5
add virtual sys table
yihaoDeng Feb 4, 2026
c83ed65
add virtual sys table
yihaoDeng Feb 4, 2026
718cfb7
add virtual sys table
yihaoDeng Feb 5, 2026
81ddca1
add virtual sys table
yihaoDeng Feb 5, 2026
f9fdc24
add virtual sys table
yihaoDeng Feb 6, 2026
55b5eaf
add virtual sys table
yihaoDeng Feb 6, 2026
6fd8bb3
update md
yihaoDeng Feb 6, 2026
4fd39b4
add virtual sys table
yihaoDeng Feb 6, 2026
9048d23
add virtual sys table
yihaoDeng Feb 6, 2026
62e780e
add virtual sys table
yihaoDeng Feb 6, 2026
b0c6df7
opt validate virtual table
yihaoDeng Feb 10, 2026
fb29fac
opt validate virtual table
yihaoDeng Feb 10, 2026
3f25fe4
enh: support tag column references in virtual table creation
yihaoDeng Feb 11, 2026
6fbd07c
enh: allow vtable char-type columns to return actual source length wi…
yihaoDeng Feb 11, 2026
eb6e572
enh: implement virtual table referencing validation
yihaoDeng Feb 11, 2026
af223b1
feat: add tests for virtual table referencing validation
yihaoDeng Feb 11, 2026
e90a64c
test: add comprehensive test cases for virtual table tag column refer…
yihaoDeng Feb 11, 2026
d3062b1
Merge branch 'enh/virtual_tag_ref' into enh/virtualTableEnh2
yihaoDeng Feb 11, 2026
fc1b232
Merge branch 'enh/virtualTableNchar' into enh/virtualTableEnh2
yihaoDeng Feb 11, 2026
0984a00
test: add comprehensive test cases for virtual table tag column refer…
yihaoDeng Feb 11, 2026
e02ce9c
enh: improve handling of variable-length columns in virtual tables
yihaoDeng Feb 11, 2026
7a33da3
remove debuglog
yihaoDeng Feb 11, 2026
397b95a
remove debuglog
yihaoDeng Feb 12, 2026
2066711
refactor code
yihaoDeng Feb 12, 2026
5eafe46
enh: enforce tag column validation for virtual table tag references
yihaoDeng Feb 12, 2026
a1f0b9e
fix: use ETableType instead of STableType in sysscanoperator.c
yihaoDeng Feb 12, 2026
f918bf6
perf: cache remote table schemas to avoid repeated RPC calls
yihaoDeng Feb 12, 2026
f684919
perf: add column name hash index for O(1) lookup in schema cache
yihaoDeng Feb 12, 2026
e8ac747
fix invalid read
yihaoDeng Feb 25, 2026
e4cb3a8
test: add performance and stress tests for virtual table functionality
yihaoDeng Feb 26, 2026
0f61600
test: add supplemental tests for NCHAR/BINARY actual length feature
yihaoDeng Feb 28, 2026
2926d36
test: add three-scenario tests for virtual table no-truncation feature
yihaoDeng Feb 28, 2026
7a8f29c
merge 3.0
yihaoDeng Mar 2, 2026
d49f8d1
fix test case
yihaoDeng Mar 2, 2026
16c77bc
fix test case
yihaoDeng Mar 2, 2026
a2dd2c6
fix compile error
yihaoDeng Mar 2, 2026
8872e87
merge 3.0
yihaoDeng Mar 3, 2026
573ad2f
fix ci warning
yihaoDeng Mar 3, 2026
5187ad1
fix ci warning
yihaoDeng Mar 3, 2026
c8aaf6f
fix ci warning
yihaoDeng Mar 4, 2026
61f6eda
fix ci warning
yihaoDeng Mar 4, 2026
6096550
fix ci warning
yihaoDeng Mar 4, 2026
d7c2d65
test: add complex scenarios for SHOW VTABLE VALIDATE
Mar 5, 2026
ae8c87b
test: add SHOW VTABLE VALIDATE FOR syntax test cases
yihaoDeng Mar 5, 2026
d3342b5
test: add comprehensive exception scenarios for SHOW VTABLE VALIDATE FOR
yihaoDeng Mar 5, 2026
43d0af4
merge 3.0
yihaoDeng Mar 6, 2026
104b132
add test case
yihaoDeng Mar 6, 2026
32eeb53
fix: resolve NULL schemaRow crash in ins_virtual_tables_referencing a…
yihaoDeng Mar 7, 2026
59d4803
refactor: rewrite test_vtable_performance.py and test_vtable_stress.p…
yihaoDeng Mar 7, 2026
fadcebc
merge 3.0
yihaoDeng Mar 10, 2026
8ddc7f1
fix merge error
yihaoDeng Mar 10, 2026
24f72ba
fix merge error
yihaoDeng Mar 10, 2026
53e4820
fix ci review error
yihaoDeng Mar 10, 2026
db92dc1
change test ci
yihaoDeng Mar 11, 2026
182e2ca
fix ci problem
yihaoDeng Mar 11, 2026
d450e1d
fix: prevent buffer overflow in vectorConvertFromVarData when vtable …
yihaoDeng Mar 11, 2026
6b214f5
fix ci problem
yihaoDeng Mar 12, 2026
c71882c
fix ci problem
yihaoDeng Mar 12, 2026
09ff349
fix ci problem
yihaoDeng Mar 12, 2026
b8bbf3a
fix ci problem
yihaoDeng Mar 12, 2026
8aa46b1
merge 3.0
yihaoDeng Mar 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/common/systable.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ extern "C" {
#define TSDB_INS_TABLE_ROLES "ins_roles"
#define TSDB_INS_TABLE_ROLE_PRIVILEGES "ins_role_privileges"
#define TSDB_INS_TABLE_ROLE_COL_PRIVILEGES "ins_role_column_privileges"
#define TSDB_INS_TABLE_VIRTUAL_TABLES_REFERENCING "ins_virtual_tables_referencing"

#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
#define TSDB_PERFS_TABLE_SMAS "perf_smas"
Expand Down
24 changes: 23 additions & 1 deletion include/common/tmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ typedef enum _mgmt_table {
TSDB_MGMT_TABLE_XNODE_AGENTS,
TSDB_MGMT_TABLE_XNODE_JOBS,
TSDB_MGMT_TABLE_XNODE_FULL,
TSDB_MGMT_TABLE_VIRTUAL_TABLES_REFERENCING,
TSDB_MGMT_TABLE_MAX,
} EShowType;

Expand Down Expand Up @@ -444,7 +445,6 @@ typedef enum ENodeType {
QUERY_NODE_DROP_TOTP_SECRET_STMT,
QUERY_NODE_ALTER_KEY_EXPIRATION_STMT,


// placeholder for [155, 180]
QUERY_NODE_SHOW_CREATE_VIEW_STMT = 181,
QUERY_NODE_SHOW_CREATE_DATABASE_STMT,
Expand Down Expand Up @@ -562,6 +562,7 @@ typedef enum ENodeType {
QUERY_NODE_SHOW_XNODE_TASKS_STMT,
QUERY_NODE_SHOW_XNODE_AGENTS_STMT,
QUERY_NODE_SHOW_XNODE_JOBS_STMT,
QUERY_NODE_SHOW_VALIDATE_VTABLE_STMT,

// logic plan node
QUERY_NODE_LOGIC_PLAN_SCAN = 1000,
Expand Down Expand Up @@ -791,6 +792,8 @@ typedef struct {
int32_t nCols;
int32_t version;
SColRef* pColRef;
int32_t nTagRefs;
SColRef* pTagRef;
} SColRefWrapper;

int32_t tEncodeSColRefWrapper(SEncoder* pCoder, const SColRefWrapper* pWrapper);
Expand Down Expand Up @@ -885,6 +888,8 @@ typedef struct {
int8_t virtualStb;
int32_t numOfColRefs;
SColRef* pColRefs;
int32_t numOfTagRefs;
SColRef* pTagRefs;
} STableMetaRsp;

typedef struct {
Expand Down Expand Up @@ -1001,6 +1006,22 @@ static FORCE_INLINE int32_t tInitDefaultSColRefWrapperByCols(SColRefWrapper* pRe
return 0;
}

static FORCE_INLINE int32_t tInitDefaultSColRefWrapperByTags(SColRefWrapper* pRef, int32_t nTags, col_id_t startColId) {
if (pRef->pTagRef) {
return TSDB_CODE_INVALID_PARA;
}
pRef->pTagRef = (SColRef*)taosMemoryCalloc(nTags, sizeof(SColRef));
if (pRef->pTagRef == NULL) {
return terrno;
}
pRef->nTagRefs = nTags;
for (int32_t i = 0; i < nTags; i++) {
pRef->pTagRef[i].hasRef = false;
pRef->pTagRef[i].id = (col_id_t)(startColId + i);
}
return 0;
}

static FORCE_INLINE SColCmprWrapper* tCloneSColCmprWrapper(const SColCmprWrapper* pSrcWrapper) {
if (pSrcWrapper->pColCmpr == NULL || pSrcWrapper->nCols == 0) {
terrno = TSDB_CODE_INVALID_PARA;
Expand Down Expand Up @@ -4866,6 +4887,7 @@ static FORCE_INLINE void tdDestroySVCreateTbReq(SVCreateTbReq* req) {
taosMemoryFreeClear(req->colCmpr.pColCmpr);
taosMemoryFreeClear(req->pExtSchemas);
taosMemoryFreeClear(req->colRef.pColRef);
taosMemoryFreeClear(req->colRef.pTagRef);
}

typedef struct {
Expand Down
13 changes: 13 additions & 0 deletions include/libs/nodes/cmdnodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ typedef struct SCreateVSubTableStmt {
SNodeList* pValsOfTags;
SNodeList* pSpecificColRefs;
SNodeList* pColRefs;
SNodeList* pSpecificTagRefs; // tag_name FROM db.table.tag_col (same as specific_column_ref)
SNodeList* pTagRefs; // db.table.tag_col (same as column_ref, positional)
Comment on lines +335 to +336
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SCreateVSubTableStmt adds pSpecificTagRefs / pTagRefs, but they are not populated by the current grammar/actions (CREATE VTABLE ... TAGS uses pValsOfTags) and there are no reads of these fields outside JSON serialization/destruction. Either wire these lists through parsing/planning (so they carry meaning) or remove them to avoid dead/duplicated state.

Suggested change
SNodeList* pSpecificTagRefs; // tag_name FROM db.table.tag_col (same as specific_column_ref)
SNodeList* pTagRefs; // db.table.tag_col (same as column_ref, positional)

Copilot uses AI. Check for mistakes.
} SCreateVSubTableStmt;

typedef struct SCreateSubTableClause {
Expand Down Expand Up @@ -1033,6 +1035,17 @@ typedef struct SAlterKeyExpirationStmt {
char strategy[ENCRYPT_KEY_EXPIRE_STRATEGY_LEN + 1];
} SAlterKeyExpirationStmt;

typedef struct SShowValidateVirtualTable {
ENodeType type;
char dbName[TSDB_DB_NAME_LEN];
char tableName[TSDB_TABLE_NAME_LEN];

void* pDbCfg; // SDbCfgInfo

void* pTableCfg; // STableCfg
int8_t superTable;
} SShowValidateVirtualTable;

typedef struct SDescribeStmt {
ENodeType type;
char dbName[TSDB_DB_NAME_LEN];
Expand Down
4 changes: 4 additions & 0 deletions include/libs/qcom/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ typedef struct SVCTableMeta {
int32_t numOfColRefs;
int32_t rversion; // virtual table's column ref's version
SColRef* colRef;
int32_t numOfTagRefs;
SColRef* tagRef;
} SVCTableMeta;
#pragma pack(pop)

Expand All @@ -133,6 +135,8 @@ typedef struct STableMeta {
int32_t numOfColRefs;
int32_t rversion; // virtual table's column ref's version
SColRef* colRef;
int32_t numOfTagRefs;
SColRef* tagRef;
// END: KEEP THIS PART SAME WITH SVCTableMeta

// if the table is TSDB_CHILD_TABLE, the following information is acquired from the corresponding super table meta
Expand Down
2 changes: 2 additions & 0 deletions include/util/tdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,8 @@ typedef enum EQuantifyType {
#define TSDB_MAX_USERS 2000
#define TSDB_MAX_ROLES 200

#define TSDB_SHOW_VALIDATE_VIRTUAL_TABLE_ERROR 512

#define PRIMARYKEY_TIMESTAMP_COL_ID 1
#define COL_REACH_END(colId, maxColId) ((colId) > (maxColId))

Expand Down
70 changes: 70 additions & 0 deletions source/common/src/msg/tmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -9829,6 +9829,15 @@ static int32_t tEncodeSTableMetaRsp(SEncoder *pEncoder, STableMetaRsp *pRsp) {
TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pRsp->ownerId));
TAOS_CHECK_RETURN(tEncodeU8(pEncoder, pRsp->flag));

// Encode tag references (new field)
TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pRsp->numOfTagRefs));
if (hasRefCol(pRsp->tableType) && pRsp->numOfTagRefs > 0) {
for (int32_t i = 0; i < pRsp->numOfTagRefs; ++i) {
SColRef *pTagRef = &pRsp->pTagRefs[i];
TAOS_CHECK_RETURN(tEncodeSColRef(pEncoder, pTagRef));
}
}

return 0;
}

Expand Down Expand Up @@ -9904,6 +9913,24 @@ static int32_t tDecodeSTableMetaRsp(SDecoder *pDecoder, STableMetaRsp *pRsp) {
TAOS_CHECK_RETURN(tDecodeU8(pDecoder, &pRsp->flag));
}

// Decode tag references (new field, backward compatible)
pRsp->numOfTagRefs = 0;
pRsp->pTagRefs = NULL;
if (!tDecodeIsEnd(pDecoder)) {
TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pRsp->numOfTagRefs));
if (hasRefCol(pRsp->tableType) && pRsp->numOfTagRefs > 0) {
pRsp->pTagRefs = taosMemoryMalloc(sizeof(SColRef) * pRsp->numOfTagRefs);
if (pRsp->pTagRefs == NULL) {
TAOS_CHECK_RETURN(terrno);
}

for (int32_t i = 0; i < pRsp->numOfTagRefs; ++i) {
SColRef *pTagRef = &pRsp->pTagRefs[i];
TAOS_CHECK_RETURN(tDecodeSColRef(pDecoder, pTagRef));
}
}
}

return 0;
}

Expand Down Expand Up @@ -10069,6 +10096,7 @@ void tFreeSTableMetaRsp(void *pRsp) {
taosMemoryFreeClear(((STableMetaRsp *)pRsp)->pSchemas);
taosMemoryFreeClear(((STableMetaRsp *)pRsp)->pSchemaExt);
taosMemoryFreeClear(((STableMetaRsp *)pRsp)->pColRefs);
taosMemoryFreeClear(((STableMetaRsp *)pRsp)->pTagRefs);
}

void tFreeSTableIndexRsp(void *info) {
Expand Down Expand Up @@ -14421,6 +14449,19 @@ int32_t tEncodeSColRefWrapper(SEncoder *pCoder, const SColRefWrapper *pWrapper)
}
}

// Encode tag references (new field, appended for backward compatibility)
TAOS_CHECK_EXIT(tEncodeI32v(pCoder, pWrapper->nTagRefs));
for (int32_t i = 0; i < pWrapper->nTagRefs; i++) {
SColRef *p = &pWrapper->pTagRef[i];
TAOS_CHECK_EXIT(tEncodeI8(pCoder, p->hasRef));
TAOS_CHECK_EXIT(tEncodeI16v(pCoder, p->id));
if (p->hasRef) {
TAOS_CHECK_EXIT(tEncodeCStr(pCoder, p->refDbName));
TAOS_CHECK_EXIT(tEncodeCStr(pCoder, p->refTableName));
TAOS_CHECK_EXIT(tEncodeCStr(pCoder, p->refColName));
}
}

_exit:
return code;
}
Expand Down Expand Up @@ -14449,9 +14490,35 @@ int32_t tDecodeSColRefWrapperEx(SDecoder *pDecoder, SColRefWrapper *pWrapper, bo
}
}

// Decode tag references (new field, backward compatible - check if data remains)
pWrapper->nTagRefs = 0;
pWrapper->pTagRef = NULL;
if (!tDecodeIsEnd(pDecoder)) {
TAOS_CHECK_EXIT(tDecodeI32v(pDecoder, &pWrapper->nTagRefs));
if (pWrapper->nTagRefs > 0) {
pWrapper->pTagRef = decoderMalloc ? (SColRef *)tDecoderMalloc(pDecoder, pWrapper->nTagRefs * sizeof(SColRef))
: (SColRef *)taosMemoryCalloc(pWrapper->nTagRefs, sizeof(SColRef));
if (pWrapper->pTagRef == NULL) {
TAOS_CHECK_EXIT(terrno);
}

for (int i = 0; i < pWrapper->nTagRefs; i++) {
SColRef *p = &pWrapper->pTagRef[i];
TAOS_CHECK_EXIT(tDecodeI8(pDecoder, (int8_t *)&p->hasRef));
TAOS_CHECK_EXIT(tDecodeI16v(pDecoder, &p->id));
if (p->hasRef) {
TAOS_CHECK_EXIT(tDecodeCStrTo(pDecoder, p->refDbName));
TAOS_CHECK_EXIT(tDecodeCStrTo(pDecoder, p->refTableName));
TAOS_CHECK_EXIT(tDecodeCStrTo(pDecoder, p->refColName));
}
}
}
}

_exit:
if (code) {
taosMemoryFree(pWrapper->pColRef);
taosMemoryFree(pWrapper->pTagRef);
}
return code;
}
Expand Down Expand Up @@ -14917,6 +14984,7 @@ void tFreeSVCreateTbRsp(void *param) {
taosMemoryFree(pRsp->pMeta->pSchemas);
taosMemoryFree(pRsp->pMeta->pSchemaExt);
taosMemoryFree(pRsp->pMeta->pColRefs);
taosMemoryFree(pRsp->pMeta->pTagRefs);
taosMemoryFree(pRsp->pMeta);
}
}
Expand Down Expand Up @@ -15414,6 +15482,7 @@ void tFreeSMAlterStbRsp(SMAlterStbRsp *pRsp) {
taosMemoryFree(pRsp->pMeta->pSchemas);
taosMemoryFree(pRsp->pMeta->pSchemaExt);
taosMemoryFree(pRsp->pMeta->pColRefs);
taosMemoryFree(pRsp->pMeta->pTagRefs);
taosMemoryFree(pRsp->pMeta);
}
}
Expand Down Expand Up @@ -15466,6 +15535,7 @@ void tFreeSMCreateStbRsp(SMCreateStbRsp *pRsp) {
taosMemoryFree(pRsp->pMeta->pSchemas);
taosMemoryFree(pRsp->pMeta->pSchemaExt);
taosMemoryFree(pRsp->pMeta->pColRefs);
taosMemoryFree(pRsp->pMeta->pTagRefs);
taosMemoryFree(pRsp->pMeta);
}
}
Expand Down
17 changes: 17 additions & 0 deletions source/common/src/systable.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define SYSTABLE_SCH_COL_NAME_LEN ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
#define SYSTABLE_SCH_VIEW_NAME_LEN ((TSDB_VIEW_NAME_LEN - 1) + VARSTR_HEADER_SIZE)


#define PERF_INSTANCE_ID_LEN (255 + VARSTR_HEADER_SIZE)
#define PERF_INSTANCE_TYPE_LEN (64 + VARSTR_HEADER_SIZE)
#define PERF_INSTANCE_DESC_LEN (512 + VARSTR_HEADER_SIZE)
Expand Down Expand Up @@ -738,6 +739,20 @@ static const SSysDbTableSchema xnodeAgentsSchema[] = {
{.name = "update_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
};

static const SSysDbTableSchema virtualTablesReferencing[] = {
{.name = "virtual_db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
{.name = "virtual_stable_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
{.name = "virtual_table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
{.name = "virtual_col_name", .bytes = SYSTABLE_SCH_COL_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
{.name = "src_db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
{.name = "src_table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
{.name = "src_column_name", .bytes = SYSTABLE_SCH_COL_NAME_LEN , .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
{.name = "type", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
{.name = "err_code", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false},
{.name = "err_msg", .bytes = TSDB_SHOW_VALIDATE_VIRTUAL_TABLE_ERROR + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
};



/**
* @brief Defines the metadata for system tables.
Expand Down Expand Up @@ -806,6 +821,8 @@ static const SSysTableMeta infosMeta[] = {
{TSDB_INS_TABLE_XNODE_TASKS, xnodeTasksSchema, tListLen(xnodeTasksSchema), true, PRIV_CAT_PRIVILEGED},
{TSDB_INS_TABLE_XNODE_AGENTS, xnodeAgentsSchema, tListLen(xnodeAgentsSchema), true, PRIV_CAT_PRIVILEGED},
{TSDB_INS_TABLE_XNODE_JOBS, xnodeTaskJobSchema, tListLen(xnodeTaskJobSchema), true, PRIV_CAT_PRIVILEGED},
{TSDB_INS_TABLE_VIRTUAL_TABLES_REFERENCING, virtualTablesReferencing, tListLen(virtualTablesReferencing), true, PRIV_CAT_PRIVILEGED},

};

static const SSysDbTableSchema connectionsSchema[] = {
Expand Down
1 change: 1 addition & 0 deletions source/dnode/mgmt/node_mgmt/src/dmTransport.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
case TDMT_SCH_MERGE_FETCH_RSP:
case TDMT_VND_SUBMIT_RSP:
case TDMT_MND_GET_DB_INFO_RSP:
case TDMT_VND_TABLE_META_RSP:
case TDMT_STREAM_FETCH_RSP:
case TDMT_STREAM_FETCH_FROM_RUNNER_RSP:
case TDMT_STREAM_FETCH_FROM_CACHE_RSP:
Expand Down
2 changes: 2 additions & 0 deletions source/dnode/mnode/impl/src/mndShow.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ static int32_t convertToRetrieveType(char *name, int32_t len) {
type = TSDB_MGMT_TABLE_ROLE_PRIVILEGES;
} else if (strncasecmp(name, TSDB_INS_TABLE_ROLE_COL_PRIVILEGES, len) == 0) {
type = TSDB_MGMT_TABLE_ROLE_COL_PRIVILEGES;
} else if (strncasecmp(name, TSDB_INS_TABLE_VIRTUAL_TABLES_REFERENCING, len) == 0) {
type = TSDB_MGMT_TABLE_VIRTUAL_TABLES_REFERENCING;
} else {
mError("invalid show name:%s len:%d", name, len);
}
Expand Down
39 changes: 39 additions & 0 deletions source/dnode/vnode/src/meta/metaEntry.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ int meteEncodeColRefEntry(SEncoder *pCoder, const SMetaEntry *pME) {
TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refColName));
}
}

// Encode tag references
TAOS_CHECK_RETURN(tEncodeI32v(pCoder, pw->nTagRefs));
for (int32_t i = 0; i < pw->nTagRefs; i++) {
SColRef *p = &pw->pTagRef[i];
TAOS_CHECK_RETURN(tEncodeI8(pCoder, p->hasRef));
TAOS_CHECK_RETURN(tEncodeI16v(pCoder, p->id));
if (p->hasRef) {
TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refDbName));
TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refTableName));
TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refColName));
}
}

return 0;
}

Expand Down Expand Up @@ -197,6 +211,31 @@ int meteDecodeColRefEntry(SDecoder *pDecoder, SMetaEntry *pME) {
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refColName));
}
}

// Decode tag references (backward compatible)
pWrapper->nTagRefs = 0;
pWrapper->pTagRef = NULL;
if (!tDecodeIsEnd(pDecoder)) {
TAOS_CHECK_RETURN(tDecodeI32v(pDecoder, &pWrapper->nTagRefs));
if (pWrapper->nTagRefs > 0) {
pWrapper->pTagRef = (SColRef *)tDecoderMalloc(pDecoder, pWrapper->nTagRefs * sizeof(SColRef));
if (pWrapper->pTagRef == NULL) {
return terrno;
}

for (int i = 0; i < pWrapper->nTagRefs; i++) {
SColRef *p = &pWrapper->pTagRef[i];
TAOS_CHECK_RETURN(tDecodeI8(pDecoder, (int8_t *)&p->hasRef));
TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &p->id));
if (p->hasRef) {
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refDbName));
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refTableName));
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refColName));
}
}
}
}

return 0;
}

Expand Down
Loading
Loading