From bb404285073138d07c2ce72101279f3e092be00c Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 6 Dec 2021 17:25:07 +0800 Subject: [PATCH] more --- source/dnode/vnode/meta/CMakeLists.txt | 2 +- source/dnode/vnode/meta/inc/metaDB.h | 2 +- source/dnode/vnode/meta/src/metaBDBImpl.c | 4 +++- source/dnode/vnode/meta/src/metaSQLiteImpl.c | 22 +++++++++++++------- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/source/dnode/vnode/meta/CMakeLists.txt b/source/dnode/vnode/meta/CMakeLists.txt index 7e5acc6450..f0aa28d7a6 100644 --- a/source/dnode/vnode/meta/CMakeLists.txt +++ b/source/dnode/vnode/meta/CMakeLists.txt @@ -1,5 +1,5 @@ set(META_DB_IMPL_LIST "BDB" "SQLITE") -set(META_DB_IMPL "BDB" CACHE STRING "Use BDB as the default META implementation") +set(META_DB_IMPL "SQLITE" CACHE STRING "Use BDB as the default META implementation") set_property(CACHE META_DB_IMPL PROPERTY STRINGS ${META_DB_IMPL_LIST}) if(META_DB_IMPL IN_LIST META_DB_IMPL_LIST) diff --git a/source/dnode/vnode/meta/inc/metaDB.h b/source/dnode/vnode/meta/inc/metaDB.h index 49a3f25c89..62b91ed48c 100644 --- a/source/dnode/vnode/meta/inc/metaDB.h +++ b/source/dnode/vnode/meta/inc/metaDB.h @@ -26,7 +26,7 @@ typedef struct SMetaDB SMetaDB; int metaOpenDB(SMeta *pMeta); void metaCloseDB(SMeta *pMeta); -int metaSaveTableToDB(SMeta *pMeta, const STbCfg *pTbOptions); +int metaSaveTableToDB(SMeta *pMeta, const STbCfg *pTbCfg); int metaRemoveTableFromDb(SMeta *pMeta, tb_uid_t uid); #ifdef __cplusplus diff --git a/source/dnode/vnode/meta/src/metaBDBImpl.c b/source/dnode/vnode/meta/src/metaBDBImpl.c index e0c21dba64..76c779fe2c 100644 --- a/source/dnode/vnode/meta/src/metaBDBImpl.c +++ b/source/dnode/vnode/meta/src/metaBDBImpl.c @@ -39,6 +39,8 @@ int metaOpenDB(SMeta *pMeta) { return -1; } + // pMeta->pDB->pEvn->set_cachesize(pMeta->pDB->pEvn, ) + ret = pMeta->pDB->pEvn->open(pMeta->pDB->pEvn, pMeta->path, DB_CREATE | DB_INIT_MPOOL, 0); if (ret != 0) { // TODO: handle error @@ -106,7 +108,7 @@ void metaCloseDB(SMeta *pMeta) { } } -int metaSaveTableToDB(SMeta *pMeta, const STbCfg *pTbOptions) { +int metaSaveTableToDB(SMeta *pMeta, const STbCfg *pTbCfg) { // TODO return 0; } diff --git a/source/dnode/vnode/meta/src/metaSQLiteImpl.c b/source/dnode/vnode/meta/src/metaSQLiteImpl.c index 37ec1cef47..12aa0a6c5d 100644 --- a/source/dnode/vnode/meta/src/metaSQLiteImpl.c +++ b/source/dnode/vnode/meta/src/metaSQLiteImpl.c @@ -95,13 +95,15 @@ void metaCloseDB(SMeta *pMeta) { // TODO } -int metaSaveTableToDB(SMeta *pMeta, const STbCfg *pTbOptions) { - char sql[256]; - char *err = NULL; - int rc; +int metaSaveTableToDB(SMeta *pMeta, const STbCfg *pTbCfg) { + char sql[256]; + char * err = NULL; + int rc; + tb_uid_t uid; - switch (pTbOptions->type) { + switch (pTbCfg->type) { case META_SUPER_TABLE: + uid = pTbCfg->stbCfg.suid; // sprintf(sql, "INSERT INTO tb VALUES (\'%s\', %" PRIu64 // ");" // "INSERT INTO stb VALUES (%" PRIu64 @@ -119,15 +121,19 @@ int metaSaveTableToDB(SMeta *pMeta, const STbCfg *pTbOptions) { } break; case META_NORMAL_TABLE: - // sprintf(sql, "INSERT INTO tb VALUES (\'%s\', %" PRIu64 - // ");" - // "INSERT INTO ntb VALUES (%" PRIu64 ", \'%s\', );"); + uid = metaGenerateUid(pMeta); + // sprintf(sql, + // "INSERT INTO tb VALUES (\'%s\', %" PRIu64 + // ");" + // "INSERT INTO ntb VALUES (%" PRIu64 ", \'%s\', );", + // pTbCfg->name, uid, uid, pTbCfg->name, ); rc = sqlite3_exec(pMeta->pDB->pDB, sql, NULL, NULL, &err); if (rc != SQLITE_OK) { printf("failed to create normal table since %s\n", err); } break; case META_CHILD_TABLE: + uid = metaGenerateUid(pMeta); // sprintf(sql, "INSERT INTO tb VALUES (\'%s\', %" PRIu64 // ");" // "INSERT INTO stb_%" PRIu64 " VALUES (%" PRIu64 ", \'%s\', );"); -- GitLab