Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
adaptun opened this issue Nov 3, 2021 · 2 comments
Labels
bug Something isn't working (correctness). Mark issues with this.

Comments

@adaptun
Copy link

adaptun commented Nov 3, 2021

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());

@turingcompl33t
Copy link
Contributor

Hey @adaptun you are correct, this is an oversight in the test and we should convert the tuple from the result set to an index key properly before performing the scan. In this particular case, this step is not strictly necessary for correctness because the schema of the index key and the output schema of the scan are identical, but in any other scenario this could lead to incorrect behavior. This project is currently ongoing in our databases course so we'll hold off from making this update for now, but once the academic term is over this is an issue that we will address.

@apavlo apavlo added the bug Something isn't working (correctness). Mark issues with this. label Nov 3, 2021
fitenne added a commit to fitenne/cmu15445 that referenced this issue Aug 3, 2022
make execute engine log out exception captured.
fix a tuple cast issue. see cmu-db/bustub#195.
add seq_scan insert delete update executor. passed simple test.
@skyzh
Copy link
Member

skyzh commented Sep 24, 2022

We'll deprecate executor test (unit test) this semester. Won't fix.

@skyzh skyzh closed this as not planned Won't fix, can't repro, duplicate, stale Sep 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working (correctness). Mark issues with this.
Projects
None yet
Development

No branches or pull requests

4 participants