Skip to content

SimpleDeleteTest in executor_test.cpp incorrectly checks if index does not have removed row anymore.  #195

Closed as not planned
@adaptun

Description

@adaptun

SimpleDeleteTest in executor_test.cpp checks if index does not have removed row anymore.

See lines 359-372:

const Tuple index_key = Tuple(result_set[0]);
std::unique_ptr<AbstractPlanNode> delete_plan;
{ delete_plan = std::make_unique<DeletePlanNode>(scan_plan1.get(), table_info->oid_); }
GetExecutionEngine()->Execute(delete_plan.get(), nullptr, GetTxn(), GetExecutorContext());

result_set.clear();

// SELECT col_a FROM test_1 WHERE col_a == 50
GetExecutionEngine()->Execute(scan_plan1.get(), &result_set, GetTxn(), GetExecutorContext());
ASSERT_TRUE(result_set.empty());

// Ensure the key was removed from the index
std::vector<RID> rids{};
index_info->index_->ScanKey(index_key, &rids, GetTxn());

I think problem here is that tuple index_key is taken from the resultset and is not converted to the index tuple.

Should be something as the following:

auto scan_key = index_key.KeyFromTuple(GetExecutorContext()->GetCatalog()->GetTable("test_1")->schema_,
                                           index_info->key_schema_, index_info->index_->GetKeyAttrs());

index_info->index_->ScanKey(scan_key, &rids, GetTxn());

Compare with SimpleRawInsertWithIndexTest where tuple from resultset is converted to the index_key -- line 260.

index_info->index_->ScanKey(index_key, &rids, GetTxn());

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working (correctness). Mark issues with this.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions