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

Bug: When executing the EqualsExpression after an update it returns wrong results #395

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions src/bin/units_access/PosUpdateScanTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Copyright (c) 2014 Hasso-Plattner-Institut fuer Softwaresystemtechnik GmbH. All rights reserved.

#include "testing/test.h"

#include "io/TransactionManager.h"
#include "io/shortcuts.h"

#include "access/PosUpdateScan.h"
#include "access/SimpleTableScan.h"
#include "access/expressions/predicates.h"
#include "access/tx/Commit.h"
#include "access/tx/ValidatePositions.h"

namespace hyrise {
namespace access {

class PosUpdateScanTests : public AccessTest {
public:
PosUpdateScanTests() {}

virtual void SetUp() {
hyrise::tx::TransactionManager::getInstance().reset();
AccessTest::SetUp();
_companies = io::Loader::shortcuts::load("test/tables/companies.tbl");
}

storage::atable_ptr_t _companies;
};



TEST_F(PosUpdateScanTests, update_and_select) {

// Do the update on microsoft
auto writeCtx = hyrise::tx::TransactionManager::getInstance().buildContext();

SimpleTableScan sts1;
sts1.setTXContext(writeCtx);
sts1.addInput(_companies);
sts1.setPredicate(new GenericExpressionValue<hyrise_int_t, std::equal_to<hyrise_int_t>>(0, 0, 2));
sts1.execute();

Json::Value update_data;
update_data["company_id"] = 7;

PosUpdateScan update;
update.setRawData(update_data);
update.setTXContext(writeCtx);
update.addInput(sts1.getResultTable());
update.execute();

Commit c;
c.addInput(update.getResultTable());
c.setTXContext(writeCtx);
c.execute();

// Read values
auto readCtx = hyrise::tx::TransactionManager::getInstance().buildContext();

ValidatePositions vp;
vp.setTXContext(readCtx);
vp.addInput(_companies);
vp.execute();

SimpleTableScan sts2;
sts2.setTXContext(readCtx);
sts2.addInput(vp.getResultTable());
// Bug-Note: Using the GenericExpressionValue works fine
// Bug-Note: Using the EqualsExpression returns wrong results
// sts2.setPredicate(new GenericExpressionValue<hyrise_int_t, std::equal_to<hyrise_int_t>>(0, 0, 7));
sts2.setPredicate(new EqualsExpression<hyrise_int_t>(0, "company_id", 7));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line (line 71) causes the bug. Replacing it with line 70 would work.
But the class EqualsExpression is still used/available in the predicate builder of the SimpleTableScan.

sts2.execute();

auto result = sts2.getResultTable();

// Do projection on reference
// Bug-Note: Without update the projection with EqualsExpression works
auto reference = io::Loader::shortcuts::load("test/reference/companies_after_one_increments.tbl");
SimpleTableScan ref_sts;
ref_sts.setTXContext(readCtx);
ref_sts.addInput(reference);
ref_sts.setPredicate(new EqualsExpression<hyrise_int_t>(0, "company_id", 7));
ref_sts.execute();

auto ref_result = ref_sts.getResultTable();

ASSERT_TABLE_EQUAL(result, ref_result);
}


} // namespace access
} // namespace hyrise