diff --git a/cmake/platform.inc b/cmake/platform.inc index 2e0e2d6af08fa529f7435b2e39fa4cdb4d293fae..1772a83fb2455f8e03ec728ab0603a596e5883cb 100755 --- a/cmake/platform.inc +++ b/cmake/platform.inc @@ -62,7 +62,7 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8) SET(TD_LINUX_64 TRUE) SET(TD_OS_DIR ${TD_COMMUNITY_DIR}/src/os/linux) - ADD_DEFINITIONS(-D_M_X64) + ADD_DEFINITIONS(-D_M_X64 -D_DEBUG_VIEW) MESSAGE(STATUS "The current platform is Linux 64-bit") ELSEIF (${CMAKE_SIZEOF_VOID_P} MATCHES 4) IF (TD_ARM) diff --git a/src/inc/tsdb.h b/src/inc/tsdb.h index 8d33e0bbf7d15187ab69528fbb85cb11b49cddc5..481e05c1022ede7dea9660a9f0cab81a88b0f2cd 100644 --- a/src/inc/tsdb.h +++ b/src/inc/tsdb.h @@ -98,6 +98,7 @@ int tsdbTableSetSName(STableCfg *config, char *sname, bool dup); void tsdbClearTableCfg(STableCfg *config); int32_t tsdbGetTableTagVal(TsdbRepoT *repo, STableId id, int32_t col, int16_t *type, int16_t *bytes, char **val); +int32_t tsdbTableGetName(TsdbRepoT *repo, STableId id, char** name); int tsdbCreateTable(TsdbRepoT *repo, STableCfg *pCfg); int tsdbDropTable(TsdbRepoT *pRepo, STableId tableId); diff --git a/src/query/src/queryExecutor.c b/src/query/src/queryExecutor.c index df282b9845a6c3c382074a2fb4c5f57554e95d39..3ad81ff4fc398c2d3ccf94ffe59131d41ed27b40 100644 --- a/src/query/src/queryExecutor.c +++ b/src/query/src/queryExecutor.c @@ -1383,8 +1383,13 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order int32_t index = pSqlFuncMsg->colInfo.colIndex; if (TSDB_COL_IS_TAG(pIndex->flag)) { - pCtx->inputBytes = pQuery->tagColList[index].bytes; - pCtx->inputType = pQuery->tagColList[index].type; + if (pIndex->colId == TSDB_TBNAME_COLUMN_INDEX) { + pCtx->inputBytes = TSDB_TABLE_NAME_LEN; + pCtx->inputType = TSDB_DATA_TYPE_BINARY; + } else { + pCtx->inputBytes = pQuery->tagColList[index].bytes; + pCtx->inputType = pQuery->tagColList[index].type; + } } else { pCtx->inputBytes = pQuery->colList[index].bytes; pCtx->inputType = pQuery->colList[index].type; @@ -2503,8 +2508,19 @@ static void doSetTagValueInParam(void *tsdb, STableId id, int32_t tagColId, tVar int16_t bytes = 0; int16_t type = 0; - tsdbGetTableTagVal(tsdb, id, tagColId, &type, &bytes, &val); + if (tagColId == TSDB_TBNAME_COLUMN_INDEX) { + tsdbTableGetName(tsdb, id, &val); + bytes = TSDB_TABLE_NAME_LEN; + type = TSDB_DATA_TYPE_BINARY; + } else { + tsdbGetTableTagVal(tsdb, id, tagColId, &type, &bytes, &val); + } + tVariantCreateFromBinary(param, val, bytes, type); + + if (tagColId == TSDB_TBNAME_COLUMN_INDEX) { + tfree(val); + } } void setTagVal(SQueryRuntimeEnv *pRuntimeEnv, STableId id, void *tsdb) { @@ -5515,9 +5531,12 @@ static int32_t createSqlFunctionExprFromMsg(SQueryTableMsg *pQueryMsg, SArithExp return code; } - type = TSDB_DATA_TYPE_DOUBLE; + type = TSDB_DATA_TYPE_DOUBLE; bytes = tDataTypeDesc[type].nSize; - } else { // parse the normal column + } else if (pExprs[i].pBase.colInfo.colId == TSDB_TBNAME_COLUMN_INDEX) { // parse the normal column + type = TSDB_DATA_TYPE_BINARY; + bytes = TSDB_TABLE_NAME_LEN; + } else{ int32_t j = getColumnIndexInSource(pQueryMsg, &pExprs[i].pBase, pTagCols); assert(j < pQueryMsg->numOfCols); diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index 7c8d1fd51ffd1bd7bbcbb020ae1c67bdea371c28..04863d1ef2e749c6d88660de6b94c7fc0e7a58aa 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -251,6 +251,18 @@ int32_t tsdbGetTableTagVal(TsdbRepoT* repo, STableId id, int32_t colId, int16_t* return 0; } +int32_t tsdbTableGetName(TsdbRepoT *repo, STableId id, char** name) { + STsdbMeta* pMeta = tsdbGetMeta(repo); + STable* pTable = tsdbGetTableByUid(pMeta, id.uid); + + *name = strndup(pTable->name, TSDB_TABLE_NAME_LEN); + if (*name == NULL) { + return -1; + } else { + return 0; + } +} + int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) { if (tsdbCheckTableCfg(pCfg) < 0) return -1;