diff --git a/src/vnode/common/inc/type.h b/src/vnode/common/inc/type.h index 1aaa95cb90baa041a98dff971cbf4ef47e7ced55..4ca80cee339f3b7978d055fa3356c3caf9141a71 100644 --- a/src/vnode/common/inc/type.h +++ b/src/vnode/common/inc/type.h @@ -1,4 +1,4 @@ -#if !defined(_TD_TYPE_H_) +#ifndef _TD_TYPE_H_ #define _TD_TYPE_H_ #include @@ -11,6 +11,7 @@ typedef enum { TD_DATATYPE_BIGINT, TD_DATATYPE_FLOAT, TD_DATATYPE_DOUBLE, + TD_DATATYPE_TIMESTAMP, TD_DATATYPE_VARCHAR, TD_DATATYPE_NCHAR, TD_DATATYPE_BINARY @@ -26,6 +27,7 @@ extern const int32_t rowDataLen[]; #define TD_DATATYPE_BIGINT_NULL #define TD_DATATYPE_FLOAT_NULL #define TD_DATATYPE_DOUBLE_NULL +#define TD_DATATYPE_TIMESTAMP_NULL #define TD_DATATYPE_VARCHAR_NULL #define TD_DATATYPE_NCHAR_NULL #define TD_DATATYPE_BINARY_NULL diff --git a/src/vnode/common/src/dataformat.c b/src/vnode/common/src/dataformat.c index 98c2cd3b08a418d953ca4463f9cedb6354c43a55..400fb0419876159c2fb4c4ed31775e2526fa5d5d 100644 --- a/src/vnode/common/src/dataformat.c +++ b/src/vnode/common/src/dataformat.c @@ -58,6 +58,7 @@ int32_t tdAppendColVal(SDataRow row, void *value, SColumn *pCol, int32_t suffixO case TD_DATATYPE_BIGINT: case TD_DATATYPE_FLOAT: case TD_DATATYPE_DOUBLE: + case TD_DATATYPE_TIMESTAMP: memcpy(dataRowIdx(row, pCol->offset + sizeof(int32_t)), value, rowDataLen[pCol->type]); if (dataRowLen(row) > suffixOffset + sizeof(int32_t)) dataRowSetLen(row, dataRowLen(row) + rowDataLen[pCol->type]); diff --git a/src/vnode/common/src/schema.c b/src/vnode/common/src/schema.c index 3fa7d41e83963f4e284eb2882596cab11aca2725..be7007ca8bb58d3547dbffb9064e5216791b4ae7 100644 --- a/src/vnode/common/src/schema.c +++ b/src/vnode/common/src/schema.c @@ -10,6 +10,7 @@ const int32_t rowDataLen[] = { sizeof(int64_t), // TD_DATATYPE_BIGINT, sizeof(float), // TD_DATATYPE_FLOAT, sizeof(double), // TD_DATATYPE_DOUBLE, + sizeof(int64_t), // TD_DATATYPE_TIMESTAMP sizeof(int32_t), // TD_DATATYPE_VARCHAR, sizeof(int32_t), // TD_DATATYPE_NCHAR, sizeof(int32_t) // TD_DATATYPE_BINARY diff --git a/src/vnode/tsdb/src/tsdbMeta.c b/src/vnode/tsdb/src/tsdbMeta.c index c6f674aa06abfcc04f98830be05aeb8197fad671..67bbcc5b1d00629fcda7d27f48fa32b011b22073 100644 --- a/src/vnode/tsdb/src/tsdbMeta.c +++ b/src/vnode/tsdb/src/tsdbMeta.c @@ -206,7 +206,8 @@ static int32_t tsdbCheckTableCfg(STableCfg *pCfg) { } STable *tsdbGetTableByUid(STsdbMeta *pMeta, int64_t uid) { - return *(STable **)taosGetDataFromHashTable(pMeta->tableMap, (char *)(&uid), sizeof(uid)); + STable *pTable = *(STable **)taosGetDataFromHashTable(pMeta->tableMap, (char *)(&uid), sizeof(uid)); + return pTable; } static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable) { diff --git a/src/vnode/tsdb/tests/tsdbTests.cpp b/src/vnode/tsdb/tests/tsdbTests.cpp index 9147b224d636eb56a5bc8bd1e2b4cdf70824b189..6c61c688f6f0a1a17a46628fd432f1804b607fd4 100644 --- a/src/vnode/tsdb/tests/tsdbTests.cpp +++ b/src/vnode/tsdb/tests/tsdbTests.cpp @@ -1,9 +1,10 @@ #include #include +#include "tsdb.h" #include "tsdbMeta.h" -TEST(TsdbTest, createTable) { +TEST(TsdbTest, DISABLED_createTable) { STsdbMeta *pMeta = tsdbCreateMeta(100); ASSERT_NE(pMeta, nullptr); @@ -23,4 +24,31 @@ TEST(TsdbTest, createTable) { STable *pTable = tsdbGetTableByUid(pMeta, config.tableId.uid); ASSERT_NE(pTable, nullptr); +} + +TEST(TsdbTest, createRepo) { + STsdbCfg *pCfg = tsdbCreateDefaultCfg(); + + tsdb_repo_t *pRepo = tsdbCreateRepo("/root/mnt/test/vnode0", pCfg, NULL); + ASSERT_NE(pRepo, nullptr); + tsdbFreeCfg(pCfg); + + STableCfg config; + config.tableId.tid = 0; + config.tableId.uid = 98868728187539L; + config.numOfCols = 5; + config.schema = tdNewSchema(config.numOfCols); + SColumn *pCol = tdNewCol(TD_DATATYPE_TIMESTAMP, 0, 0); + tdColCpy(schemaColAt(config.schema, 0), pCol); + tdFreeCol(pCol); + for (int i = 1; i < schemaNCols(config.schema); i++) { + pCol = tdNewCol(TD_DATATYPE_BIGINT, i, 0); + tdColCpy(schemaColAt(config.schema, i), pCol); + tdFreeCol(pCol); + } + + tsdbCreateTable(pRepo, &config); + tdFreeSchema(config.schema); + + tsdbDropRepo(pRepo); } \ No newline at end of file