Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/new-framework-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ concurrency:
jobs:
test-new-cases:
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && !contains(github.event.pull_request.title, '[manual-only]'))
uses: taosdata/.github/.github/workflows/new-framework-test.yml@test-ci-49
uses: taosdata/.github/.github/workflows/new-framework-test.yml@main
with:
tdinternal: false
specified_source_branch: ${{ github.event_name == 'pull_request' && 'unavailable' || inputs.specified_source_branch }}
Expand Down
6 changes: 4 additions & 2 deletions source/dnode/vnode/src/meta/metaTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ int32_t updataTableColRef(SColRefWrapper *pWp, const SSchema *pSchema, int8_t ad
return 0;
}

int metaUpdateMetaRsp(tb_uid_t uid, char *tbName, SSchemaWrapper *pSchema, STableMetaRsp *pMetaRsp) {
int metaUpdateMetaRsp(tb_uid_t uid, char *tbName, SSchemaWrapper *pSchema, int64_t ownerId, STableMetaRsp *pMetaRsp) {
pMetaRsp->pSchemas = taosMemoryMalloc(pSchema->nCols * sizeof(SSchema));
if (NULL == pMetaRsp->pSchemas) {
return terrno;
Expand All @@ -165,14 +165,15 @@ int metaUpdateMetaRsp(tb_uid_t uid, char *tbName, SSchemaWrapper *pSchema, STabl
pMetaRsp->rversion = 1;
pMetaRsp->tuid = uid;
pMetaRsp->virtualStb = false; // super table will never be processed here
if (ownerId != 0) pMetaRsp->ownerId = ownerId;

memcpy(pMetaRsp->pSchemas, pSchema->pSchema, pSchema->nCols * sizeof(SSchema));

return 0;
}

int32_t metaUpdateVtbMetaRsp(SMetaEntry *pEntry, char *tbName, SSchemaWrapper *pSchema, SColRefWrapper *pRef,
STableMetaRsp *pMetaRsp, int8_t tableType) {
int64_t ownerId, STableMetaRsp *pMetaRsp, int8_t tableType) {
int32_t code = TSDB_CODE_SUCCESS;
SHashObj* pColRefHash = NULL;
if (!pRef) {
Expand Down Expand Up @@ -235,6 +236,7 @@ int32_t metaUpdateVtbMetaRsp(SMetaEntry *pEntry, char *tbName, SSchemaWrapper *p
pMetaRsp->virtualStb = false; // super table will never be processed here
pMetaRsp->numOfColRefs = pRef->nCols;
pMetaRsp->rversion = pRef->version;
if (ownerId != 0) pMetaRsp->ownerId = ownerId;

taosHashCleanup(pColRefHash);
return code;
Expand Down
41 changes: 26 additions & 15 deletions source/dnode/vnode/src/meta/metaTable2.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
#include "meta.h"

extern int32_t metaHandleEntry2(SMeta *pMeta, const SMetaEntry *pEntry);
extern int32_t metaUpdateMetaRsp(tb_uid_t uid, char *tbName, SSchemaWrapper *pSchema, STableMetaRsp *pMetaRsp);
extern int32_t metaUpdateMetaRsp(tb_uid_t uid, char *tbName, SSchemaWrapper *pSchema, int64_t ownerId,
STableMetaRsp *pMetaRsp);
extern int32_t metaUpdateVtbMetaRsp(SMetaEntry *pEntry, char *tbName, SSchemaWrapper *pSchema, SColRefWrapper *pRef,
STableMetaRsp *pMetaRsp, int8_t tableType);
int64_t ownerId, STableMetaRsp *pMetaRsp, int8_t tableType);
extern int32_t metaFetchEntryByUid(SMeta *pMeta, int64_t uid, SMetaEntry **ppEntry);
extern int32_t metaFetchEntryByName(SMeta *pMeta, const char *name, SMetaEntry **ppEntry);
extern void metaFetchEntryFree(SMetaEntry **ppEntry);
Expand Down Expand Up @@ -456,7 +457,7 @@ static int32_t metaBuildCreateNormalTableRsp(SMeta *pMeta, SMetaEntry *pEntry, S
return terrno;
}

code = metaUpdateMetaRsp(pEntry->uid, pEntry->name, &pEntry->ntbEntry.schemaRow, *ppRsp);
code = metaUpdateMetaRsp(pEntry->uid, pEntry->name, &pEntry->ntbEntry.schemaRow, pEntry->ntbEntry.ownerId, *ppRsp);
if (code) {
taosMemoryFreeClear(*ppRsp);
return code;
Expand Down Expand Up @@ -535,7 +536,7 @@ static int32_t metaBuildCreateVirtualNormalTableRsp(SMeta *pMeta, SMetaEntry *pE
return terrno;
}

code = metaUpdateVtbMetaRsp(pEntry, pEntry->name, &pEntry->ntbEntry.schemaRow, &pEntry->colRef, *ppRsp,
code = metaUpdateVtbMetaRsp(pEntry, pEntry->name, &pEntry->ntbEntry.schemaRow, &pEntry->colRef, pEntry->ntbEntry.ownerId, *ppRsp,
TSDB_VIRTUAL_NORMAL_TABLE);
if (code) {
taosMemoryFreeClear(*ppRsp);
Expand Down Expand Up @@ -603,7 +604,7 @@ static int32_t metaBuildCreateVirtualChildTableRsp(SMeta *pMeta, SMetaEntry *pEn
return terrno;
}

code = metaUpdateVtbMetaRsp(pEntry, pEntry->name, NULL, &pEntry->colRef, *ppRsp, TSDB_VIRTUAL_CHILD_TABLE);
code = metaUpdateVtbMetaRsp(pEntry, pEntry->name, NULL, &pEntry->colRef, 0, *ppRsp, TSDB_VIRTUAL_CHILD_TABLE);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

There's an inconsistency in handling ownerId for virtual child tables. Here, on creation, ownerId is hardcoded to 0. However, in metaAlterTableColumnRef and metaRemoveTableColumnRef (lines 2010 and 2114), the ownerId for a virtual child table is correctly retrieved from its super table. The ownerId should also be set from the super table during creation to ensure consistency.

  SMetaEntry *pStbEntry = NULL;
  int64_t ownerId = 0;
  if (metaFetchEntryByUid(pMeta, pEntry->ctbEntry.suid, &pStbEntry) == 0) {
    ownerId = pStbEntry->stbEntry.ownerId;
    metaFetchEntryFree(&pStbEntry);
  }
  code = metaUpdateVtbMetaRsp(pEntry, pEntry->name, NULL, &pEntry->colRef, ownerId, *ppRsp, TSDB_VIRTUAL_CHILD_TABLE);

if (code) {
taosMemoryFreeClear(*ppRsp);
return code;
Expand Down Expand Up @@ -912,7 +913,8 @@ int32_t metaAddTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq, ST
}

if (pEntry->type == TSDB_VIRTUAL_NORMAL_TABLE) {
code = metaUpdateVtbMetaRsp(pEntry, pReq->tbName, pSchema, &pEntry->colRef, pRsp, pEntry->type);
code = metaUpdateVtbMetaRsp(pEntry, pReq->tbName, pSchema, &pEntry->colRef, pEntry->ntbEntry.ownerId, pRsp,
pEntry->type);
if (code) {
metaError("vgId:%d, %s failed at %s:%d since %s, uid:%" PRId64 " name:%s version:%" PRId64, TD_VID(pMeta->pVnode),
__func__, __FILE__, __LINE__, tstrerror(code), pEntry->uid, pReq->tbName, version);
Expand All @@ -929,7 +931,7 @@ int32_t metaAddTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq, ST
}
}
} else {
code = metaUpdateMetaRsp(pEntry->uid, pReq->tbName, pSchema, pRsp);
code = metaUpdateMetaRsp(pEntry->uid, pReq->tbName, pSchema, pEntry->ntbEntry.ownerId, pRsp);
if (code) {
metaError("vgId:%d, %s failed at %s:%d since %s, uid:%" PRId64 " name:%s version:%" PRId64, TD_VID(pMeta->pVnode),
__func__, __FILE__, __LINE__, tstrerror(code), pEntry->uid, pReq->tbName, version);
Expand Down Expand Up @@ -1059,7 +1061,8 @@ int32_t metaDropTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq, S

// build response
if (pEntry->type == TSDB_VIRTUAL_NORMAL_TABLE) {
code = metaUpdateVtbMetaRsp(pEntry, pReq->tbName, pSchema, &pEntry->colRef, pRsp, pEntry->type);
code = metaUpdateVtbMetaRsp(pEntry, pReq->tbName, pSchema, &pEntry->colRef, pEntry->ntbEntry.ownerId, pRsp,
pEntry->type);
if (code) {
metaError("vgId:%d, %s failed at %s:%d since %s, uid:%" PRId64 " name:%s version:%" PRId64, TD_VID(pMeta->pVnode),
__func__, __FILE__, __LINE__, tstrerror(code), pEntry->uid, pReq->tbName, version);
Expand All @@ -1076,7 +1079,7 @@ int32_t metaDropTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq, S
}
}
} else {
code = metaUpdateMetaRsp(pEntry->uid, pReq->tbName, pSchema, pRsp);
code = metaUpdateMetaRsp(pEntry->uid, pReq->tbName, pSchema, pEntry->ntbEntry.ownerId, pRsp);
if (code) {
metaError("vgId:%d, %s failed at %s:%d since %s, uid:%" PRId64 " name:%s version:%" PRId64, TD_VID(pMeta->pVnode),
__func__, __FILE__, __LINE__, tstrerror(code), pEntry->uid, pReq->tbName, version);
Expand Down Expand Up @@ -1163,7 +1166,8 @@ int32_t metaAlterTableColumnName(SMeta *pMeta, int64_t version, SVAlterTbReq *pR

// build response
if (pEntry->type == TSDB_VIRTUAL_NORMAL_TABLE) {
code = metaUpdateVtbMetaRsp(pEntry, pReq->tbName, pSchema, &pEntry->colRef, pRsp, pEntry->type);
code = metaUpdateVtbMetaRsp(pEntry, pReq->tbName, pSchema, &pEntry->colRef, pEntry->ntbEntry.ownerId, pRsp,
pEntry->type);
if (code) {
metaError("vgId:%d, %s failed at %s:%d since %s, uid:%" PRId64 " name:%s version:%" PRId64, TD_VID(pMeta->pVnode),
__func__, __FILE__, __LINE__, tstrerror(code), pEntry->uid, pReq->tbName, version);
Expand All @@ -1180,7 +1184,7 @@ int32_t metaAlterTableColumnName(SMeta *pMeta, int64_t version, SVAlterTbReq *pR
}
}
} else {
code = metaUpdateMetaRsp(pEntry->uid, pReq->tbName, pSchema, pRsp);
code = metaUpdateMetaRsp(pEntry->uid, pReq->tbName, pSchema, pEntry->ntbEntry.ownerId, pRsp);
if (code) {
metaError("vgId:%d, %s failed at %s:%d since %s, uid:%" PRId64 " name:%s version:%" PRId64, TD_VID(pMeta->pVnode),
__func__, __FILE__, __LINE__, tstrerror(code), pEntry->uid, pReq->tbName, version);
Expand Down Expand Up @@ -1278,7 +1282,8 @@ int32_t metaAlterTableColumnBytes(SMeta *pMeta, int64_t version, SVAlterTbReq *p

// build response
if (pEntry->type == TSDB_VIRTUAL_NORMAL_TABLE) {
code = metaUpdateVtbMetaRsp(pEntry, pReq->tbName, pSchema, &pEntry->colRef, pRsp, pEntry->type);
code = metaUpdateVtbMetaRsp(pEntry, pReq->tbName, pSchema, &pEntry->colRef, pEntry->ntbEntry.ownerId, pRsp,
pEntry->type);
if (code) {
metaError("vgId:%d, %s failed at %s:%d since %s, uid:%" PRId64 " name:%s version:%" PRId64, TD_VID(pMeta->pVnode),
__func__, __FILE__, __LINE__, tstrerror(code), pEntry->uid, pReq->tbName, version);
Expand All @@ -1295,7 +1300,7 @@ int32_t metaAlterTableColumnBytes(SMeta *pMeta, int64_t version, SVAlterTbReq *p
}
}
} else {
code = metaUpdateMetaRsp(pEntry->uid, pReq->tbName, pSchema, pRsp);
code = metaUpdateMetaRsp(pEntry->uid, pReq->tbName, pSchema, pEntry->ntbEntry.ownerId, pRsp);
if (code) {
metaError("vgId:%d, %s failed at %s:%d since %s, uid:%" PRId64 " name:%s version:%" PRId64, TD_VID(pMeta->pVnode),
__func__, __FILE__, __LINE__, tstrerror(code), pEntry->uid, pReq->tbName, version);
Expand Down Expand Up @@ -2000,7 +2005,10 @@ int32_t metaAlterTableColumnRef(SMeta *pMeta, int64_t version, SVAlterTbReq *pRe
}

// build response
code = metaUpdateVtbMetaRsp(pEntry, pReq->tbName, pSchema, &pEntry->colRef, pRsp, pEntry->type);
code = metaUpdateVtbMetaRsp(
pEntry, pReq->tbName, pSchema, &pEntry->colRef,
pEntry->type == TSDB_VIRTUAL_CHILD_TABLE ? pSuper->stbEntry.ownerId : pEntry->ntbEntry.ownerId, pRsp,
pEntry->type);
if (code) {
metaError("vgId:%d, %s failed at %s:%d since %s, uid:%" PRId64 " name:%s version:%" PRId64, TD_VID(pMeta->pVnode),
__func__, __FILE__, __LINE__, tstrerror(code), pEntry->uid, pReq->tbName, version);
Expand Down Expand Up @@ -2101,7 +2109,10 @@ int32_t metaRemoveTableColumnRef(SMeta *pMeta, int64_t version, SVAlterTbReq *pR
}

// build response
code = metaUpdateVtbMetaRsp(pEntry, pReq->tbName, pSchema, &pEntry->colRef, pRsp, pEntry->type);
code = metaUpdateVtbMetaRsp(
pEntry, pReq->tbName, pSchema, &pEntry->colRef,
pEntry->type == TSDB_VIRTUAL_CHILD_TABLE ? pSuper->stbEntry.ownerId : pEntry->ntbEntry.ownerId, pRsp,
pEntry->type);
if (code) {
metaError("vgId:%d, %s failed at %s:%d since %s, uid:%" PRId64 " name:%s version:%" PRId64, TD_VID(pMeta->pVnode),
__func__, __FILE__, __LINE__, tstrerror(code), pEntry->uid, pReq->tbName, version);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from new_test_framework.utils import tdLog, tdSql, tdCom
import datetime

class TestScalarSubQuery4a:
class TestScalarSubQuery4a1:
updatecfgDict = {'debugFlag': 131, 'asyncLog': 1, 'qDebugFlag': 131, 'cDebugFlag': 131, 'rpcDebugFlag': 131}
clientCfgDict = {'debugFlag': 131, 'asyncLog': 1, 'qDebugFlag': 131, 'cDebugFlag': 131, 'rpcDebugFlag': 131}
updatecfgDict["clientCfg"] = clientCfgDict
caseName = "test_scalar_sub_query4a"
caseName = "test_scalar_sub_query4a1"
currentDir = os.path.dirname(os.path.abspath(__file__))
mainIdx = 0
secondIdx = 0
Expand Down Expand Up @@ -105,7 +105,7 @@ class TestScalarSubQuery4a:
def setup_class(cls):
tdLog.debug(f"start to execute {__file__}")

def test_scalar_sub_query4a(self):
def test_scalar_sub_query4a1(self):
"""scalar sub query test case

1. Prepare data.
Expand Down Expand Up @@ -182,12 +182,11 @@ def execCase(self):
self.querySql = self.subSqls[self.mainIdx].replace("{scalarSql}", "(" + self.subSqls[self.secondIdx] + ")")
self.querySql = self.querySql.replace("{scalarSql}", self.scalarSqls[self.subIdx])
self.querySql = self.querySql.replace("{tableName}", self.tableNames[self.tableIdx])
#self.querySql = self.querySql.replace("{ntableName}", self.tableNames[self.ntableIdx])

self.generated_queries_file.write("explain " + self.querySql.strip() + "\G;\n")
self.generated_queries_file.write("explain verbose true " + self.querySql.strip() + "\G;\n")
#self.generated_queries_file.write("explain analyze " + self.querySql.strip() + "\G\n")
self.generated_queries_file.write("explain analyze verbose true " + self.querySql.strip() + "\G;\n")
#self.generated_queries_file.write("explain analyze verbose true " + self.querySql.strip() + "\G;\n")
self.generated_queries_file.flush()

self.generated_queries_file.close()
Expand Down
Loading
Loading