From 78f7871f50c50456b13ae428803c763a125685a6 Mon Sep 17 00:00:00 2001 From: Jin Hai Date: Tue, 15 Oct 2024 23:58:51 +0800 Subject: [PATCH] Fix UT fail Signed-off-by: Jin Hai --- src/unit_test/main/infinity.cpp | 4 +- .../storage/bg_task/cleanup_task.cpp | 8 +- src/unit_test/storage/meta/catalog.cpp | 77 +++++++++---------- src/unit_test/storage/meta/db_meta.cpp | 18 ++--- .../meta/entry/table_collection_entry.cpp | 2 +- src/unit_test/storage/txn/database_txn.cpp | 38 ++++----- src/unit_test/storage/txn/table_txn.cpp | 20 ++--- .../storage/wal/catalog_delta_entry.cpp | 3 + .../storage/wal/catalog_delta_replay.cpp | 8 +- src/unit_test/storage/wal/recycle_log.cpp | 4 +- src/unit_test/storage/wal/wal_entry.cpp | 4 +- src/unit_test/storage/wal/wal_replay.cpp | 12 +-- 12 files changed, 99 insertions(+), 99 deletions(-) diff --git a/src/unit_test/main/infinity.cpp b/src/unit_test/main/infinity.cpp index edc5f7d279..70fb36b326 100644 --- a/src/unit_test/main/infinity.cpp +++ b/src/unit_test/main/infinity.cpp @@ -45,8 +45,8 @@ TEST_F(InfinityTest, test1) { { QueryResult result = infinity->ListDatabases(); - // EXPECT_EQ(result.result_table_->row_count(), 1); // Bug - EXPECT_EQ(result.result_table_->ColumnCount(), 1u); + EXPECT_EQ(result.result_table_->row_count(), 1); + EXPECT_EQ(result.result_table_->ColumnCount(), 3u); EXPECT_EQ(result.result_table_->GetColumnNameById(0), "database"); EXPECT_EQ(result.result_table_->DataBlockCount(), 1u); SharedPtr data_block = result.result_table_->GetDataBlockById(0); diff --git a/src/unit_test/storage/bg_task/cleanup_task.cpp b/src/unit_test/storage/bg_task/cleanup_task.cpp index 97600986c3..e99a731d25 100644 --- a/src/unit_test/storage/bg_task/cleanup_task.cpp +++ b/src/unit_test/storage/bg_task/cleanup_task.cpp @@ -77,7 +77,7 @@ TEST_P(CleanupTaskTest, test_delete_db_simple) { auto db_name = MakeShared("db1"); { auto *txn = txn_mgr->BeginTxn(MakeUnique("create db1")); - txn->CreateDatabase(*db_name, ConflictType::kError); + txn->CreateDatabase(db_name, ConflictType::kError, MakeShared()); txn_mgr->CommitTxn(txn); } WaitFlushDeltaOp(storage); @@ -106,7 +106,7 @@ TEST_P(CleanupTaskTest, test_delete_db_complex) { auto db_name = MakeShared("db1"); { auto *txn = txn_mgr->BeginTxn(MakeUnique("create db1")); - txn->CreateDatabase(*db_name, ConflictType::kError); + txn->CreateDatabase(db_name, ConflictType::kError, MakeShared()); txn_mgr->CommitTxn(txn); } { @@ -117,12 +117,12 @@ TEST_P(CleanupTaskTest, test_delete_db_complex) { } { auto *txn = txn_mgr->BeginTxn(MakeUnique("create db1")); - txn->CreateDatabase(*db_name, ConflictType::kError); + txn->CreateDatabase(db_name, ConflictType::kError, MakeShared()); txn_mgr->RollBackTxn(txn); } { auto *txn = txn_mgr->BeginTxn(MakeUnique("create db1")); - txn->CreateDatabase(*db_name, ConflictType::kError); + txn->CreateDatabase(db_name, ConflictType::kError, MakeShared()); txn_mgr->CommitTxn(txn); } { diff --git a/src/unit_test/storage/meta/catalog.cpp b/src/unit_test/storage/meta/catalog.cpp index 5881a2a3b4..625743af3b 100644 --- a/src/unit_test/storage/meta/catalog.cpp +++ b/src/unit_test/storage/meta/catalog.cpp @@ -71,7 +71,7 @@ TEST_P(CatalogTest, simple_test1) { // create db in empty catalog should be success { - auto [base_entry, status] = catalog->CreateDatabase("db1", txn1->TxnID(), txn1->BeginTS(), txn_mgr); + auto [base_entry, status] = catalog->CreateDatabase(MakeShared("db1"), MakeShared(), txn1->TxnID(), txn1->BeginTS(), txn_mgr); EXPECT_TRUE(status.ok()); // store this entry databases["db1"] = base_entry; @@ -127,7 +127,7 @@ TEST_P(CatalogTest, simple_test2) { // create db in empty catalog should be success { - Status status = txn1->CreateDatabase("db1", ConflictType::kError); + Status status = txn1->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); } @@ -177,7 +177,7 @@ TEST_P(CatalogTest, concurrent_test) { auto write_routine = [&](int start, Txn *txn) { for (int db_id = start; db_id < 1000; db_id += 2) { String db_name = "db" + std::to_string(db_id); - Status status = txn->CreateDatabase(db_name, ConflictType::kError); + Status status = txn->CreateDatabase(MakeShared(db_name), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); } }; @@ -260,10 +260,9 @@ TEST_P(CatalogTest, get_db_info_test) { // start txn2 auto *txn2 = txn_mgr->BeginTxn(MakeUnique("get db")); - // create db in empty catalog should be success { - auto [base_entry, status] = catalog->CreateDatabase("db1", txn1->TxnID(), txn1->BeginTS(), txn_mgr); + auto [base_entry, status] = catalog->CreateDatabase(MakeShared("db1"), MakeShared(), txn1->TxnID(), txn1->BeginTS(), txn_mgr); EXPECT_TRUE(status.ok()); } @@ -271,7 +270,7 @@ TEST_P(CatalogTest, get_db_info_test) { auto [db_info1, status1] = catalog->GetDatabaseInfo("db1", txn1->TxnID(), txn1->BeginTS()); // should be visible to same txn EXPECT_TRUE(status1.ok()); - std::cout<<*(db_info1->db_name_)<db_name_) << std::endl; EXPECT_STREQ("db1", db_info1->db_name_->c_str()); // should not be visible to other txn @@ -306,7 +305,7 @@ TEST_P(CatalogTest, get_table_info_test) { // start txn1 auto *txn1 = txn_mgr->BeginTxn(MakeUnique("create table")); - //create table, get table info, drop table + // create table, get table info, drop table { Vector> columns; { @@ -314,12 +313,12 @@ TEST_P(CatalogTest, get_table_info_test) { constraints.insert(ConstraintType::kNotNull); i64 column_id = 0; auto embeddingInfo = MakeShared(EmbeddingDataType::kElemFloat, 128); - auto column_def_ptr = - MakeShared(column_id, MakeShared(LogicalType::kEmbedding, embeddingInfo), "col1", constraints); + auto column_def_ptr = MakeShared(column_id, MakeShared(LogicalType::kEmbedding, embeddingInfo), "col1", constraints); columns.emplace_back(column_def_ptr); } auto tbl1_def = MakeUnique(MakeShared("default_db"), MakeShared("tbl1"), columns); - auto [table_entry, status] = catalog->CreateTable("default_db", txn1->TxnID(), txn1->BeginTS(), std::move(tbl1_def), ConflictType::kError, txn_mgr); + auto [table_entry, status] = + catalog->CreateTable("default_db", txn1->TxnID(), txn1->BeginTS(), std::move(tbl1_def), ConflictType::kError, txn_mgr); EXPECT_TRUE(status.ok()); auto [table_info, status1] = catalog->GetTableInfo("default_db", "tbl1", txn1); @@ -342,7 +341,7 @@ TEST_P(CatalogTest, get_table_index_info_test) { // start txn1 auto *txn1 = txn_mgr->BeginTxn(MakeUnique("create index")); - //create table + // create table { Vector> columns; { @@ -350,12 +349,12 @@ TEST_P(CatalogTest, get_table_index_info_test) { constraints.insert(ConstraintType::kNotNull); i64 column_id = 0; auto embeddingInfo = MakeShared(EmbeddingDataType::kElemFloat, 128); - auto column_def_ptr = - MakeShared(column_id, MakeShared(LogicalType::kEmbedding, embeddingInfo), "col1", constraints); + auto column_def_ptr = MakeShared(column_id, MakeShared(LogicalType::kEmbedding, embeddingInfo), "col1", constraints); columns.emplace_back(column_def_ptr); } auto tbl1_def = MakeUnique(MakeShared("default_db"), MakeShared("tbl1"), columns); - auto [table_entry, status] = catalog->CreateTable("default_db", txn1->TxnID(), txn1->BeginTS(), std::move(tbl1_def), ConflictType::kError, txn_mgr); + auto [table_entry, status] = + catalog->CreateTable("default_db", txn1->TxnID(), txn1->BeginTS(), std::move(tbl1_def), ConflictType::kError, txn_mgr); EXPECT_TRUE(status.ok()); } @@ -383,20 +382,21 @@ TEST_P(CatalogTest, get_table_index_info_test) { EXPECT_EQ(index_status.ok(), true); } - //get index info + // get index info { auto [index_info, status] = catalog->GetTableIndexInfo("default_db", "tbl1", "hnsw_index", txn1->TxnID(), txn1->BeginTS()); EXPECT_TRUE(status.ok()); EXPECT_STREQ("hnsw_index", index_info->index_name_->c_str()); } - //drop index + // drop index { - auto [index_entry, status] = catalog->DropIndex("default_db", "tbl1", "hnsw_index", ConflictType::kError, txn1->TxnID(), txn1->BeginTS(), txn_mgr); + auto [index_entry, status] = + catalog->DropIndex("default_db", "tbl1", "hnsw_index", ConflictType::kError, txn1->TxnID(), txn1->BeginTS(), txn_mgr); EXPECT_TRUE(status.ok()); } - //drop table + // drop table { auto [table_entry, status] = catalog->DropTableByName("default_db", "tbl1", ConflictType::kError, txn1->TxnID(), txn1->BeginTS(), txn_mgr); EXPECT_TRUE(status.ok()); @@ -414,7 +414,7 @@ TEST_P(CatalogTest, remove_index_test) { // start txn1 auto *txn1 = txn_mgr->BeginTxn(MakeUnique("create index")); - //create table + // create table { Vector> columns; { @@ -422,12 +422,12 @@ TEST_P(CatalogTest, remove_index_test) { constraints.insert(ConstraintType::kNotNull); i64 column_id = 0; auto embeddingInfo = MakeShared(EmbeddingDataType::kElemFloat, 128); - auto column_def_ptr = - MakeShared(column_id, MakeShared(LogicalType::kEmbedding, embeddingInfo), "col1", constraints); + auto column_def_ptr = MakeShared(column_id, MakeShared(LogicalType::kEmbedding, embeddingInfo), "col1", constraints); columns.emplace_back(column_def_ptr); } auto tbl1_def = MakeUnique(MakeShared("default_db"), MakeShared("tbl1"), columns); - auto [table_entry, status] = catalog->CreateTable("default_db", txn1->TxnID(), txn1->BeginTS(), std::move(tbl1_def), ConflictType::kError, txn_mgr); + auto [table_entry, status] = + catalog->CreateTable("default_db", txn1->TxnID(), txn1->BeginTS(), std::move(tbl1_def), ConflictType::kError, txn_mgr); EXPECT_TRUE(status.ok()); } @@ -455,7 +455,7 @@ TEST_P(CatalogTest, remove_index_test) { EXPECT_EQ(index_status.ok(), true); } - //remove index + // remove index { auto [index_entry, index_status] = catalog->GetIndexByName("default_db", "tbl1", "hnsw_index", txn1->TxnID(), txn1->BeginTS()); EXPECT_TRUE(index_status.ok()); @@ -463,7 +463,7 @@ TEST_P(CatalogTest, remove_index_test) { EXPECT_TRUE(status.ok()); } - //drop table + // drop table { auto [table_entry, status] = catalog->DropTableByName("default_db", "tbl1", ConflictType::kError, txn1->TxnID(), txn1->BeginTS(), txn_mgr); EXPECT_TRUE(status.ok()); @@ -482,7 +482,7 @@ TEST_P(CatalogTest, roll_back_append_test) { // start txn1 auto *txn1 = txn_mgr->BeginTxn(MakeUnique("create table")); - //create table + // create table { Vector> columns; { @@ -490,12 +490,12 @@ TEST_P(CatalogTest, roll_back_append_test) { constraints.insert(ConstraintType::kNotNull); i64 column_id = 0; auto embeddingInfo = MakeShared(EmbeddingDataType::kElemFloat, 128); - auto column_def_ptr = - MakeShared(column_id, MakeShared(LogicalType::kEmbedding, embeddingInfo), "col1", constraints); + auto column_def_ptr = MakeShared(column_id, MakeShared(LogicalType::kEmbedding, embeddingInfo), "col1", constraints); columns.emplace_back(column_def_ptr); } auto tbl1_def = MakeUnique(MakeShared("default_db"), MakeShared("tbl1"), columns); - auto [table_entry, status] = catalog->CreateTable("default_db", txn1->TxnID(), txn1->BeginTS(), std::move(tbl1_def), ConflictType::kError, txn_mgr); + auto [table_entry, status] = + catalog->CreateTable("default_db", txn1->TxnID(), txn1->BeginTS(), std::move(tbl1_def), ConflictType::kError, txn_mgr); EXPECT_TRUE(status.ok()); } @@ -503,7 +503,6 @@ TEST_P(CatalogTest, roll_back_append_test) { auto [table_entry, status] = catalog->GetTableByName("default_db", "tbl1", txn1->TxnID(), txn1->BeginTS()); EXPECT_TRUE(status.ok()); - auto txn_store = txn1->GetTxnTableStore(table_entry); txn_store->SetAppendState(MakeUnique(txn_store->GetBlocks())); Catalog::Append(table_entry, txn1->TxnID(), (void *)txn_store, txn1->CommitTS(), buffer_mgr); @@ -511,7 +510,6 @@ TEST_P(CatalogTest, roll_back_append_test) { } } - TEST_P(CatalogTest, roll_back_delete_test) { using namespace infinity; @@ -522,7 +520,7 @@ TEST_P(CatalogTest, roll_back_delete_test) { // start txn1 auto *txn1 = txn_mgr->BeginTxn(MakeUnique("create table")); - //create table + // create table { Vector> columns; { @@ -530,12 +528,12 @@ TEST_P(CatalogTest, roll_back_delete_test) { constraints.insert(ConstraintType::kNotNull); i64 column_id = 0; auto embeddingInfo = MakeShared(EmbeddingDataType::kElemFloat, 128); - auto column_def_ptr = - MakeShared(column_id, MakeShared(LogicalType::kEmbedding, embeddingInfo), "col1", constraints); + auto column_def_ptr = MakeShared(column_id, MakeShared(LogicalType::kEmbedding, embeddingInfo), "col1", constraints); columns.emplace_back(column_def_ptr); } auto tbl1_def = MakeUnique(MakeShared("default_db"), MakeShared("tbl1"), columns); - auto [table_entry, status] = catalog->CreateTable("default_db", txn1->TxnID(), txn1->BeginTS(), std::move(tbl1_def), ConflictType::kError, txn_mgr); + auto [table_entry, status] = + catalog->CreateTable("default_db", txn1->TxnID(), txn1->BeginTS(), std::move(tbl1_def), ConflictType::kError, txn_mgr); EXPECT_TRUE(status.ok()); } @@ -545,7 +543,7 @@ TEST_P(CatalogTest, roll_back_delete_test) { auto txn_store = txn1->GetTxnTableStore(table_entry); Catalog::Delete(table_entry, txn1->TxnID(), (void *)txn_store, txn1->CommitTS(), txn_store->GetDeleteStateRef()); - EXPECT_THROW(Catalog::RollbackDelete(table_entry, txn1->TxnID(), txn_store->GetDeleteStateRef(), buffer_mgr),UnrecoverableException); + EXPECT_THROW(Catalog::RollbackDelete(table_entry, txn1->TxnID(), txn_store->GetDeleteStateRef(), buffer_mgr), UnrecoverableException); } } @@ -559,7 +557,7 @@ TEST_P(CatalogTest, roll_back_write_test) { // start txn1 auto *txn1 = txn_mgr->BeginTxn(MakeUnique("create table")); - //create table + // create table { Vector> columns; { @@ -567,12 +565,12 @@ TEST_P(CatalogTest, roll_back_write_test) { constraints.insert(ConstraintType::kNotNull); i64 column_id = 0; auto embeddingInfo = MakeShared(EmbeddingDataType::kElemFloat, 128); - auto column_def_ptr = - MakeShared(column_id, MakeShared(LogicalType::kEmbedding, embeddingInfo), "col1", constraints); + auto column_def_ptr = MakeShared(column_id, MakeShared(LogicalType::kEmbedding, embeddingInfo), "col1", constraints); columns.emplace_back(column_def_ptr); } auto tbl1_def = MakeUnique(MakeShared("default_db"), MakeShared("tbl1"), columns); - auto [table_entry, status] = catalog->CreateTable("default_db", txn1->TxnID(), txn1->BeginTS(), std::move(tbl1_def), ConflictType::kError, txn_mgr); + auto [table_entry, status] = + catalog->CreateTable("default_db", txn1->TxnID(), txn1->BeginTS(), std::move(tbl1_def), ConflictType::kError, txn_mgr); EXPECT_TRUE(status.ok()); } @@ -580,7 +578,6 @@ TEST_P(CatalogTest, roll_back_write_test) { auto [table_entry, status] = catalog->GetTableByName("default_db", "tbl1", txn1->TxnID(), txn1->BeginTS()); EXPECT_TRUE(status.ok()); - auto txn_store = txn1->GetTxnTableStore(table_entry); txn_store->SetAppendState(MakeUnique(txn_store->GetBlocks())); Catalog::Append(table_entry, txn1->TxnID(), (void *)txn_store, txn1->CommitTS(), buffer_mgr); diff --git a/src/unit_test/storage/meta/db_meta.cpp b/src/unit_test/storage/meta/db_meta.cpp index c6478ae3fa..f05bb0301d 100644 --- a/src/unit_test/storage/meta/db_meta.cpp +++ b/src/unit_test/storage/meta/db_meta.cpp @@ -36,9 +36,9 @@ TEST_P(DBMetaTest, to_string_test) { // create db in empty catalog should be success { - auto [base_entry, status] = catalog->CreateDatabase("db1", txn1->TxnID(), txn1->BeginTS(), txn_mgr); + auto [base_entry, status] = catalog->CreateDatabase(MakeShared("db1"), MakeShared(), txn1->TxnID(), txn1->BeginTS(), txn_mgr); EXPECT_TRUE(status.ok()); - std::cout<db_meta_->ToString()->c_str()<db_meta_->ToString()->c_str() << std::endl; ASSERT_STREQ(base_entry->db_meta_->ToString()->c_str(), "DBMeta, db name: db1, entry count: 1"); } @@ -46,7 +46,7 @@ TEST_P(DBMetaTest, to_string_test) { { auto [base_entry, status] = catalog->DropDatabase("db1", txn1->TxnID(), txn1->BeginTS(), txn_mgr); EXPECT_TRUE(status.ok()); - std::cout<db_meta_->ToString()->c_str()<db_meta_->ToString()->c_str() << std::endl; ASSERT_STREQ(base_entry->db_meta_->ToString()->c_str(), "DBMeta, db name: db1, entry count: 0"); } @@ -62,9 +62,9 @@ TEST_P(DBMetaTest, empty_db_entry_test) { // create db in empty catalog should be success { - auto [base_entry, status] = catalog->CreateDatabase("db1", txn1->TxnID(), txn1->BeginTS(), txn_mgr); + auto [base_entry, status] = catalog->CreateDatabase(MakeShared("db1"), MakeShared(), txn1->TxnID(), txn1->BeginTS(), txn_mgr); EXPECT_TRUE(status.ok()); - std::cout<db_meta_->ToString()->c_str()<db_meta_->ToString()->c_str() << std::endl; EXPECT_FALSE(base_entry->db_meta_->Empty()); } @@ -72,7 +72,7 @@ TEST_P(DBMetaTest, empty_db_entry_test) { { auto [base_entry, status] = catalog->DropDatabase("db1", txn1->TxnID(), txn1->BeginTS(), txn_mgr); EXPECT_TRUE(status.ok()); - std::cout<db_meta_->ToString()->c_str()<db_meta_->ToString()->c_str() << std::endl; EXPECT_TRUE(base_entry->db_meta_->Empty()); } @@ -88,9 +88,9 @@ TEST_P(DBMetaTest, get_all_db_entry_test) { // create db in empty catalog should be success { - auto [base_entry, status] = catalog->CreateDatabase("db1", txn1->TxnID(), txn1->BeginTS(), txn_mgr); + auto [base_entry, status] = catalog->CreateDatabase(MakeShared("db1"), MakeShared(), txn1->TxnID(), txn1->BeginTS(), txn_mgr); EXPECT_TRUE(status.ok()); - std::cout<db_meta_->ToString()->c_str()<db_meta_->ToString()->c_str() << std::endl; EXPECT_EQ(base_entry->db_meta_->GetAllEntries().size(), 1); } @@ -98,7 +98,7 @@ TEST_P(DBMetaTest, get_all_db_entry_test) { { auto [base_entry, status] = catalog->DropDatabase("db1", txn1->TxnID(), txn1->BeginTS(), txn_mgr); EXPECT_TRUE(status.ok()); - std::cout<db_meta_->ToString()->c_str()<db_meta_->ToString()->c_str() << std::endl; EXPECT_EQ(base_entry->db_meta_->GetAllEntries().size(), 0); } diff --git a/src/unit_test/storage/meta/entry/table_collection_entry.cpp b/src/unit_test/storage/meta/entry/table_collection_entry.cpp index 6702b3d0a9..4742fa1805 100644 --- a/src/unit_test/storage/meta/entry/table_collection_entry.cpp +++ b/src/unit_test/storage/meta/entry/table_collection_entry.cpp @@ -106,7 +106,7 @@ TEST_P(TableEntryTest, test2) { Txn *new_txn = txn_mgr->BeginTxn(MakeUnique("create db1")); // Txn1: Create db1, OK - Status status = new_txn->CreateDatabase("db1", ConflictType::kError); + Status status = new_txn->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn1: Create tbl1, OK diff --git a/src/unit_test/storage/txn/database_txn.cpp b/src/unit_test/storage/txn/database_txn.cpp index 1656327835..58ad6ec244 100644 --- a/src/unit_test/storage/txn/database_txn.cpp +++ b/src/unit_test/storage/txn/database_txn.cpp @@ -48,7 +48,7 @@ TEST_P(DBTxnTest, test1) { Txn *new_txn = txn_mgr->BeginTxn(MakeUnique("create db1")); // Txn1: Create db1, OK - Status status = new_txn->CreateDatabase("db1", ConflictType::kError); + Status status = new_txn->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); // Txn1: Get db1, OK auto [db_entry1, status1] = new_txn->GetDatabase("db1"); @@ -96,7 +96,7 @@ TEST_P(DBTxnTest, test20) { Txn *new_txn = txn_mgr->BeginTxn(MakeUnique("create db1")); // Txn1: Create db1, OK - Status status = new_txn->CreateDatabase("db1", ConflictType::kError); + Status status = new_txn->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn1: Commit, OK @@ -115,7 +115,7 @@ TEST_P(DBTxnTest, test20) { EXPECT_TRUE(status.ok()); // Txn2: Create db1, OK - status = new_txn->CreateDatabase("db1", ConflictType::kError); + status = new_txn->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn2: Get db1, OK @@ -135,7 +135,7 @@ TEST_P(DBTxnTest, test20) { EXPECT_NE(db_entry3, nullptr); // Txn3: Create db1, NOT OK - status = new_txn->CreateDatabase("db1", ConflictType::kError); + status = new_txn->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(!status.ok()); // Txn3: Commit, OK @@ -151,11 +151,11 @@ TEST_P(DBTxnTest, test2) { // Txn1: Create db1, OK - Status status = new_txn->CreateDatabase("db1", ConflictType::kError); + Status status = new_txn->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn1: Create db1, duplicated,NOT OK - status = new_txn->CreateDatabase("db1", ConflictType::kError); + status = new_txn->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(!status.ok()); // Txn1: Drop db1, OK @@ -178,7 +178,7 @@ TEST_P(DBTxnTest, test2) { EXPECT_FALSE(status2.ok()); // Txn2: Create db1, OK - status = new_txn->CreateDatabase("db1", ConflictType::kError); + status = new_txn->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn2: Get db1, OK @@ -197,7 +197,7 @@ TEST_P(DBTxnTest, test2) { EXPECT_NE(db_entry4, nullptr); // Txn3: Create db1, NOT OK - status = new_txn->CreateDatabase("db1", ConflictType::kError); + status = new_txn->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(!status.ok()); // Txn3: Commit, OK @@ -219,11 +219,11 @@ TEST_P(DBTxnTest, test3) { Txn *new_txn2 = txn_mgr->BeginTxn(MakeUnique("create db1")); // Txn1: Create db1, OK - Status status = new_txn1->CreateDatabase("db1", ConflictType::kError); + Status status = new_txn1->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn2: Create db1, NOT OK, WW-conflict - status = new_txn2->CreateDatabase("db1", ConflictType::kError); + status = new_txn2->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(!status.ok()); // Txn1: Commit, OK @@ -247,14 +247,14 @@ TEST_P(DBTxnTest, test4) { Txn *new_txn2 = txn_mgr->BeginTxn(MakeUnique("create db1")); // Txn1: Create db1, OK - Status status = new_txn1->CreateDatabase("db1", ConflictType::kError); + Status status = new_txn1->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn1: Commit, OK txn_mgr->CommitTxn(new_txn1); // Txn2: Create db1, NOT OK - status = new_txn2->CreateDatabase("db1", ConflictType::kError); + status = new_txn2->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(!status.ok()); // Txn2: Commit, OK @@ -269,7 +269,7 @@ TEST_P(DBTxnTest, test5) { Txn *new_txn = txn_mgr->BeginTxn(MakeUnique("create db1")); // Txn1: Create db1, OK - Status status = new_txn->CreateDatabase("db1", ConflictType::kError); + Status status = new_txn->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn1: Rollback, OK @@ -303,18 +303,18 @@ TEST_P(DBTxnTest, test6) { // Txn1: Create db1, OK - Status status = new_txn1->CreateDatabase("db1", ConflictType::kError); + Status status = new_txn1->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn2: Create db1, NOT OK, WW-conflict - status = new_txn2->CreateDatabase("db1", ConflictType::kError); + status = new_txn2->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(!status.ok()); // Txn1: Commit, OK txn_mgr->RollBackTxn(new_txn1); // Txn2: Since txn1 is rollback, txn2 db1, OK, no conflict - status = new_txn2->CreateDatabase("db1", ConflictType::kError); + status = new_txn2->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn2: Commit, OK @@ -348,11 +348,11 @@ TEST_P(DBTxnTest, test7) { // Txn1: Create db1, OK - Status status = new_txn1->CreateDatabase("db1", ConflictType::kError); + Status status = new_txn1->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn2: Create db1, NOT OK, WW-conflict - status = new_txn2->CreateDatabase("db1", ConflictType::kError); + status = new_txn2->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(!status.ok()); // Txn1: Drop db1, OK @@ -360,7 +360,7 @@ TEST_P(DBTxnTest, test7) { EXPECT_TRUE(status.ok()); // Txn2: Create db1, OK - status = new_txn2->CreateDatabase("db1", ConflictType::kError); + status = new_txn2->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn1: Commit, OK diff --git a/src/unit_test/storage/txn/table_txn.cpp b/src/unit_test/storage/txn/table_txn.cpp index daddcf8166..bbdedf99f5 100644 --- a/src/unit_test/storage/txn/table_txn.cpp +++ b/src/unit_test/storage/txn/table_txn.cpp @@ -87,7 +87,7 @@ TEST_P(TableTxnTest, test1) { Txn *new_txn = txn_mgr->BeginTxn(MakeUnique("create db")); // Txn1: Create db1, OK - Status status = new_txn->CreateDatabase("db1", ConflictType::kError); + Status status = new_txn->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn1: Create tbl1, OK @@ -122,7 +122,7 @@ TEST_P(TableTxnTest, test2) { Txn *new_txn = txn_mgr->BeginTxn(MakeUnique("create db")); // Txn1: Create db1, OK - Status status = new_txn->CreateDatabase("db1", ConflictType::kError); + Status status = new_txn->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn1: Create tbl1, OK @@ -174,7 +174,7 @@ TEST_P(TableTxnTest, test3) { Txn *new_txn = txn_mgr->BeginTxn(MakeUnique("create db")); // Txn1: Create db1, OK - Status status = new_txn->CreateDatabase("db1", ConflictType::kError); + Status status = new_txn->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn1: Create tbl1, OK @@ -224,7 +224,7 @@ TEST_P(TableTxnTest, test4) { Txn *new_txn2 = txn_mgr->BeginTxn(MakeUnique("create db")); // Txn1: Create db1, OK - Status status = new_txn1->CreateDatabase("db1", ConflictType::kError); + Status status = new_txn1->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn1: Create tbl1, OK @@ -257,7 +257,7 @@ TEST_P(TableTxnTest, test5) { Txn *new_txn1 = txn_mgr->BeginTxn(MakeUnique("create db")); // Txn1: Create db1, OK - Status status = new_txn1->CreateDatabase("db1", ConflictType::kError); + Status status = new_txn1->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn1: Commit, OK @@ -295,7 +295,7 @@ TEST_P(TableTxnTest, test6) { Txn *new_txn1 = txn_mgr->BeginTxn(MakeUnique("create db")); // Txn1: Create db1, OK - Status status = new_txn1->CreateDatabase("db1", ConflictType::kError); + Status status = new_txn1->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn1: Commit, OK @@ -329,7 +329,7 @@ TEST_P(TableTxnTest, test7) { Txn *new_txn1 = txn_mgr->BeginTxn(MakeUnique("create db")); // Txn1: Create db1, OK - Status status = new_txn1->CreateDatabase("db1", ConflictType::kError); + Status status = new_txn1->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn2: Create tbl1, OK @@ -363,7 +363,7 @@ TEST_P(TableTxnTest, test8) { Txn *new_txn1 = txn_mgr->BeginTxn(MakeUnique("create db")); // Txn1: Create db1, OK - Status status = new_txn1->CreateDatabase("db1", ConflictType::kError); + Status status = new_txn1->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn1: Commit, OK @@ -409,7 +409,7 @@ TEST_P(TableTxnTest, test9) { Txn *new_txn1 = txn_mgr->BeginTxn(MakeUnique("create db")); // Txn1: Create db1, OK - Status status = new_txn1->CreateDatabase("db1", ConflictType::kError); + Status status = new_txn1->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn1: Commit, OK @@ -453,7 +453,7 @@ TEST_P(TableTxnTest, test10) { Txn *new_txn1 = txn_mgr->BeginTxn(MakeUnique("create db")); // Txn1: Create db1, OK - Status status = new_txn1->CreateDatabase("db1", ConflictType::kError); + Status status = new_txn1->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_TRUE(status.ok()); // Txn1: Commit, OK diff --git a/src/unit_test/storage/wal/catalog_delta_entry.cpp b/src/unit_test/storage/wal/catalog_delta_entry.cpp index d8a9605c20..8c83f9562c 100644 --- a/src/unit_test/storage/wal/catalog_delta_entry.cpp +++ b/src/unit_test/storage/wal/catalog_delta_entry.cpp @@ -83,6 +83,7 @@ TEST_P(CatalogDeltaEntryTest, test_DeltaOpEntry) { auto op = MakeUnique(); op->encode_ = MakeUnique(fmt::format("#{}", db_name)); op->db_entry_dir_ = db_dir; + op->comment_ = MakeShared(); catalog_delta_entry1->operations().push_back(std::move(op)); } { @@ -200,6 +201,7 @@ TEST_P(CatalogDeltaEntryTest, MergeEntries) { op2->merge_flag_ = MergeFlag::kDelete; op1_same_name->db_entry_dir_ = op2->db_entry_dir_ = op1->db_entry_dir_ = db_dir; + op1_same_name->comment_ = op2->comment_ = op1->comment_ = MakeShared(); auto op1_copy = MakeUnique(*op1); op1_copy->merge_flag_ = MergeFlag::kUpdate; @@ -388,6 +390,7 @@ TEST_P(CatalogDeltaEntryTest, ComplicateMergeEntries) { op1->encode_ = MakeUnique(fmt::format("#{}", *db_name)); op1->db_entry_dir_ = db_dir; + op1->comment_ = MakeShared(); op1->merge_flag_ = merge_flag; op1->commit_ts_ = commit_ts; delta_entry->operations().push_back(std::move(op1)); diff --git a/src/unit_test/storage/wal/catalog_delta_replay.cpp b/src/unit_test/storage/wal/catalog_delta_replay.cpp index 0fe740d192..21f8c4a807 100644 --- a/src/unit_test/storage/wal/catalog_delta_replay.cpp +++ b/src/unit_test/storage/wal/catalog_delta_replay.cpp @@ -128,8 +128,8 @@ TEST_P(CatalogDeltaReplayTest, replay_db_entry) { { auto *txn = txn_mgr->BeginTxn(MakeUnique("create db")); - txn->CreateDatabase(*db_name1, ConflictType::kError); - txn->CreateDatabase(*db_name2, ConflictType::kError); + txn->CreateDatabase(db_name1, ConflictType::kError, MakeShared()); + txn->CreateDatabase(db_name2, ConflictType::kError, MakeShared()); txn->DropDatabase(*db_name2, ConflictType::kError); auto [db_entry, status] = txn->GetDatabase(*db_name1); @@ -140,7 +140,7 @@ TEST_P(CatalogDeltaReplayTest, replay_db_entry) { } { auto *txn = txn_mgr->BeginTxn(MakeUnique("create db")); - txn->CreateDatabase(*db_name3, ConflictType::kError); + txn->CreateDatabase(db_name3, ConflictType::kError, MakeShared()); txn_mgr->RollBackTxn(txn); } WaitFlushDeltaOp(storage); @@ -911,7 +911,7 @@ TEST_P(CatalogDeltaReplayTest, replay_table_single_index_named_db) { // create database auto *txn = txn_mgr->BeginTxn(MakeUnique("create db")); - txn->CreateDatabase(*db_name, ConflictType::kError); + txn->CreateDatabase(db_name, ConflictType::kError, MakeShared()); auto [db_entry, status] = txn->GetDatabase(*db_name); EXPECT_TRUE(status.ok()); diff --git a/src/unit_test/storage/wal/recycle_log.cpp b/src/unit_test/storage/wal/recycle_log.cpp index 436564861a..cd8046fb9d 100644 --- a/src/unit_test/storage/wal/recycle_log.cpp +++ b/src/unit_test/storage/wal/recycle_log.cpp @@ -81,7 +81,7 @@ TEST_P(RecycleLogTest, recycle_wal_after_delta_checkpoint) { } { // put create after drop to prevent the merge delta result is empty auto *txn = txn_mgr->BeginTxn(MakeUnique("create db")); - auto status = txn->CreateDatabase("db1", ConflictType::kIgnore); + auto status = txn->CreateDatabase(MakeShared("db1"), ConflictType::kIgnore, MakeShared()); ASSERT_TRUE(status.ok()); txn_mgr->CommitTxn(txn); } @@ -176,7 +176,7 @@ TEST_P(RecycleLogTest, recycle_wal_after_full_checkpoint) { } { // put create after drop to prevent the merge delta result is empty auto *txn = txn_mgr->BeginTxn(MakeUnique("create db")); - auto status = txn->CreateDatabase("db1", ConflictType::kIgnore); + auto status = txn->CreateDatabase(MakeShared("db1"), ConflictType::kIgnore, MakeShared()); ASSERT_TRUE(status.ok()); txn_mgr->CommitTxn(txn); } diff --git a/src/unit_test/storage/wal/wal_entry.cpp b/src/unit_test/storage/wal/wal_entry.cpp index 0c4dc4a989..6611f977bb 100644 --- a/src/unit_test/storage/wal/wal_entry.cpp +++ b/src/unit_test/storage/wal/wal_entry.cpp @@ -98,7 +98,7 @@ void MockWalFile(const String &wal_file_path, const String &ckp_file_path, const SizeT row_count = DEFAULT_VECTOR_SIZE; auto entry = MakeShared(); - entry->cmds_.push_back(MakeShared("default2", "AAA_default2")); + entry->cmds_.push_back(MakeShared("default2", "default2_comment", "AAA_default2")); entry->cmds_.push_back(MakeShared("default_db", "BBB_default", MockTableDesc2())); WalSegmentInfo segment_info = MakeSegmentInfo(row_count, commit_ts, 2); entry->cmds_.push_back(MakeShared("default_db", "tbl1", std::move(segment_info))); @@ -200,7 +200,7 @@ TEST_F(WalEntryTest, ReadWrite) { RemoveDbDirs(); infinity::InfinityContext::instance().Init(nullptr); SharedPtr entry = MakeShared(); - entry->cmds_.push_back(MakeShared("db1", "AAA_db1")); + entry->cmds_.push_back(MakeShared("db1", "default2_comment", "AAA_db1")); entry->cmds_.push_back(MakeShared("db1")); entry->cmds_.push_back(MakeShared("db1", "BBB_tb1", MockTableDesc2())); entry->cmds_.push_back(MakeShared("db1", "tbl1")); diff --git a/src/unit_test/storage/wal/wal_replay.cpp b/src/unit_test/storage/wal/wal_replay.cpp index 8ac04a92d3..a84abb289c 100644 --- a/src/unit_test/storage/wal/wal_replay.cpp +++ b/src/unit_test/storage/wal/wal_replay.cpp @@ -102,22 +102,22 @@ TEST_P(WalReplayTest, wal_replay_database) { { auto *txn = txn_mgr->BeginTxn(MakeUnique("create db")); - txn->CreateDatabase("db1", ConflictType::kIgnore); + txn->CreateDatabase(MakeShared("db1"), ConflictType::kIgnore, MakeShared()); txn_mgr->CommitTxn(txn); } { auto *txn = txn_mgr->BeginTxn(MakeUnique("create db")); - txn->CreateDatabase("db2", ConflictType::kIgnore); + txn->CreateDatabase(MakeShared("db2"), ConflictType::kIgnore, MakeShared()); txn_mgr->CommitTxn(txn); } { auto *txn = txn_mgr->BeginTxn(MakeUnique("create db")); - txn->CreateDatabase("db3", ConflictType::kIgnore); + txn->CreateDatabase(MakeShared("db3"), ConflictType::kIgnore, MakeShared()); txn_mgr->CommitTxn(txn); } { auto *txn = txn_mgr->BeginTxn(MakeUnique("create db")); - txn->CreateDatabase("db4", ConflictType::kIgnore); + txn->CreateDatabase(MakeShared("db4"), ConflictType::kIgnore, MakeShared()); txn_mgr->CommitTxn(txn); } { @@ -129,7 +129,7 @@ TEST_P(WalReplayTest, wal_replay_database) { } { auto *txn = txn_mgr->BeginTxn(MakeUnique("create db")); - txn->CreateDatabase("db5", ConflictType::kIgnore); + txn->CreateDatabase(MakeShared("db5"), ConflictType::kIgnore, MakeShared()); txn_mgr->CommitTxn(txn); } { @@ -164,7 +164,7 @@ TEST_P(WalReplayTest, wal_replay_database) { } { auto *txn = txn_mgr->BeginTxn(MakeUnique("create db")); - Status status = txn->CreateDatabase("db1", ConflictType::kError); + Status status = txn->CreateDatabase(MakeShared("db1"), ConflictType::kError, MakeShared()); EXPECT_EQ(status.ok(), true); txn_mgr->CommitTxn(txn); }