add bdb test

This commit is contained in:
Hongze Cheng 2021-12-02 09:43:11 +08:00
parent a44b2423f2
commit dd436399cf
2 changed files with 25 additions and 1 deletions

3
deps/CMakeLists.txt vendored
View File

@ -87,6 +87,9 @@ if(${BUILD_WITH_BDB})
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/bdb/libdb.a"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/bdb"
)
target_link_libraries(bdb
INTERFACE pthread
)
endif(${BUILD_WITH_BDB})
# SQLite

View File

@ -1,7 +1,28 @@
#include <stdio.h>
#include <stdlib.h>
#include "db.h"
// refer: https://docs.oracle.com/cd/E17076_05/html/gsg/C/BerkeleyDB-Core-C-GSG.pdf
int main(int argc, char const *argv[]) {
printf("Hello world!\n");
DB * db;
int ret;
uint32_t flags;
ret = db_create(&db, NULL, 0);
if (ret != 0) {
exit(1);
}
flags = DB_CREATE;
ret = db->open(db, NULL, "test.db", NULL, DB_BTREE, flags, 0);
if (ret != 0) {
exit(1);
}
db->close(db, 0);
return 0;
}