Skip to content

Commit

Permalink
fix testcase using sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
kuron99 committed Dec 4, 2024
1 parent 3aedbe3 commit 333ec37
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 66 deletions.
52 changes: 0 additions & 52 deletions mock/jogasaki/utils/tables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ namespace storage = yugawara::storage;

// built-in sequences definition ids
constexpr static sequence_definition_id h_id_sequence = 0;
constexpr static sequence_definition_id tseq0_c0_sequence = 1;
constexpr static sequence_definition_id tseq1_c0_sequence = 2;

void add_benchmark_tables(storage::configurable_provider& provider) {
namespace type = ::takatori::type;
Expand Down Expand Up @@ -806,56 +804,6 @@ void add_test_tables(storage::configurable_provider& provider) {
index_features
});
}
{
auto s1 = std::make_shared<storage::sequence>(
tseq0_c0_sequence,
"tseq0_c0_sequence"
);
provider.add_sequence(s1);
auto t = provider.add_table({
"TSEQ0",
{
{ "C0", type::int8(), nullity{false}, {s1} },
{ "C1", type::int8(), nullity{true} },
},
});
provider.add_index({
t,
t->simple_name(),
{
t->columns()[0],
},
{
t->columns()[1],
},
index_features
});
}
{
auto s1 = std::make_shared<storage::sequence>(
tseq1_c0_sequence,
"tseq1_c0_sequence"
);
provider.add_sequence(s1);
auto t = provider.add_table({
"TSEQ1",
{
{ "C0", type::int8(), nullity{false}, {s1} },
{ "C1", type::int8(), nullity{true} },
},
});
auto i = provider.add_index({
t,
"TSEQ1",
{
t->columns()[0],
},
{
t->columns()[1],
},
index_features
});
}
{
std::shared_ptr<::yugawara::storage::table> t = provider.add_table({
"TSECONDARY",
Expand Down
19 changes: 5 additions & 14 deletions test/jogasaki/api/sequence_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ class sequence_test :
void SetUp() override {
auto cfg = std::make_shared<configuration>();
db_setup(cfg);
auto* impl = db_impl();
utils::add_test_tables(*impl->tables());
register_kvs_storage(*impl->kvs_db(), *impl->tables());
impl->initialize_from_providers(); // needed to initialize the sequence manager based on table definition
}

void TearDown() override {
Expand All @@ -76,19 +72,14 @@ class sequence_test :
using namespace std::string_view_literals;

TEST_F(sequence_test, generate_primary_key) {
execute_statement( "INSERT INTO TSEQ0 (C1) VALUES (10)");
execute_statement( "INSERT INTO TSEQ0 (C1) VALUES (20)");
execute_statement( "INSERT INTO TSEQ0 (C1) VALUES (30)");
execute_statement("create table t (C1 INT)");
execute_statement("INSERT INTO t (C1) VALUES (10)");
execute_statement("INSERT INTO t (C1) VALUES (10)");
execute_statement("INSERT INTO t (C1) VALUES (10)");

std::vector<mock::basic_record> result{};
execute_query("SELECT * FROM TSEQ0 ORDER BY C1", result);
execute_query("SELECT * FROM t ORDER BY C1", result);
ASSERT_EQ(3, result.size());
auto meta = result[0].record_meta();
auto s0 = result[0].ref().get_value<std::int64_t>(meta->value_offset(0));
auto s1 = result[1].ref().get_value<std::int64_t>(meta->value_offset(0));
auto s2 = result[2].ref().get_value<std::int64_t>(meta->value_offset(0));
EXPECT_LT(s0, s1);
EXPECT_LT(s1, s2);
}

TEST_F(sequence_test, recovery) {
Expand Down

0 comments on commit 333ec37

Please sign in to comment.