Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit 48d2877

Browse files
authored
Merge branch 'master' into fix/travis_failing_tests_ignored
2 parents 56957bf + bf33cd6 commit 48d2877

File tree

8 files changed

+130
-43
lines changed

8 files changed

+130
-43
lines changed

Jenkinsfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ pipeline {
5959
sh 'python ./script/validators/source_validator.py'
6060
sh 'mkdir build'
6161
sh 'cd build && cmake -DCMAKE_BUILD_TYPE=Release -DCOVERALLS=False .. && make -j4'
62+
sh 'cd build && make check -j4 || true'
63+
// sh 'cd build && cp -pr test /job/'
64+
sh 'cd build && make benchmark -j4'
65+
sh 'cd build && make install'
66+
sh 'cd build && bash ../script/testing/psql/psql_test.sh'
67+
sh 'cd build && python ../script/validators/jdbc_validator.py'
6268
}
6369
}
6470

script/testing/psql/psql_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ PELOTON_DIR="$CODE_SOURCE_DIR/../../.."
1515
PELOTON_PID=""
1616
PELOTON_PORT="57721"
1717
PELOTON_HOST="localhost"
18-
PELOTON_USER="postgres"
18+
PELOTON_USER="default_database"
1919
PELOTON_PASS="postgres"
2020
PELOTON_ARGS='sslmode=disable'
2121

src/catalog/catalog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ ResultType Catalog::CreateTable(const std::string &database_name,
271271
table_oid, column.GetName(), column_id, column.GetOffset(),
272272
column.GetType(), column.IsInlined(), column.GetConstraints(),
273273
pool_.get(), txn);
274-
column_id++;
275274

276275
// Create index on unique single column
277276
if (column.IsUnique()) {
@@ -282,6 +281,7 @@ ResultType Catalog::CreateTable(const std::string &database_name,
282281
LOG_DEBUG("Added a UNIQUE index on %s in %s.", col_name.c_str(),
283282
table_name.c_str());
284283
}
284+
column_id++;
285285
}
286286
CreatePrimaryIndex(database_object->GetDatabaseOid(), table_oid, txn);
287287
return ResultType::SUCCESS;

src/executor/index_scan_executor.cpp

Lines changed: 69 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ bool IndexScanExecutor::ExecPrimaryIndexLookup() {
199199
auto current_txn = executor_context_->GetTransaction();
200200
auto &manager = catalog::Manager::GetInstance();
201201
std::vector<ItemPointer> visible_tuple_locations;
202-
std::map<oid_t, std::vector<oid_t>> visible_tuples;
203202

204203
#ifdef LOG_TRACE_ENABLED
205204
int num_tuples_examined = 0;
@@ -326,27 +325,53 @@ bool IndexScanExecutor::ExecPrimaryIndexLookup() {
326325
LOG_TRACE("%ld tuples after pruning boundaries",
327326
visible_tuple_locations.size());
328327

328+
// Add the tuple locations to the result vector in the order returned by
329+
// the index scan. We might end up reading the same tile group multiple
330+
// times. However, this is necessary to adhere to the ORDER BY clause
331+
oid_t current_tile_group_oid = INVALID_OID;
332+
std::vector<oid_t> tuples;
333+
329334
for (auto &visible_tuple_location : visible_tuple_locations) {
330-
visible_tuples[visible_tuple_location.block]
331-
.push_back(visible_tuple_location.offset);
332-
}
335+
if (current_tile_group_oid == INVALID_OID) {
336+
current_tile_group_oid = visible_tuple_location.block;
337+
}
338+
if (current_tile_group_oid == visible_tuple_location.block) {
339+
tuples.push_back(visible_tuple_location.offset);
340+
} else {
341+
// Since the tile_group_oids differ, fill in the current tile group
342+
// into the result vector
343+
auto &manager = catalog::Manager::GetInstance();
344+
auto tile_group = manager.GetTileGroup(current_tile_group_oid);
345+
std::unique_ptr<LogicalTile> logical_tile(LogicalTileFactory::GetTile());
346+
// Add relevant columns to logical tile
347+
logical_tile->AddColumns(tile_group, full_column_ids_);
348+
logical_tile->AddPositionList(std::move(tuples));
349+
if (column_ids_.size() != 0) {
350+
logical_tile->ProjectColumns(full_column_ids_, column_ids_);
351+
}
352+
result_.push_back(logical_tile.release());
333353

334-
// Construct a logical tile for each block
335-
for (auto tuples : visible_tuples) {
336-
auto &manager = catalog::Manager::GetInstance();
337-
auto tile_group = manager.GetTileGroup(tuples.first);
354+
// Change the current_tile_group_oid and add the current tuple
355+
tuples.clear();
356+
current_tile_group_oid = visible_tuple_location.block;
357+
tuples.push_back(visible_tuple_location.offset);
358+
}
359+
}
338360

361+
// Add the remaining tuples to the result vector
362+
if ((current_tile_group_oid != INVALID_OID) && (!tuples.empty())) {
363+
auto tile_group = manager.GetTileGroup(current_tile_group_oid);
339364
std::unique_ptr<LogicalTile> logical_tile(LogicalTileFactory::GetTile());
340365
// Add relevant columns to logical tile
341366
logical_tile->AddColumns(tile_group, full_column_ids_);
342-
logical_tile->AddPositionList(std::move(tuples.second));
367+
logical_tile->AddPositionList(std::move(tuples));
343368
if (column_ids_.size() != 0) {
344369
logical_tile->ProjectColumns(full_column_ids_, column_ids_);
345370
}
346-
347371
result_.push_back(logical_tile.release());
348372
}
349373

374+
350375
done_ = true;
351376

352377
LOG_TRACE("Result tiles : %lu", result_.size());
@@ -408,7 +433,6 @@ bool IndexScanExecutor::ExecSecondaryIndexLookup() {
408433
auto current_txn = executor_context_->GetTransaction();
409434

410435
std::vector<ItemPointer> visible_tuple_locations;
411-
std::map<oid_t, std::vector<oid_t>> visible_tuples;
412436
auto &manager = catalog::Manager::GetInstance();
413437

414438
// Quickie Hack
@@ -567,24 +591,49 @@ bool IndexScanExecutor::ExecSecondaryIndexLookup() {
567591
// Check whether the boundaries satisfy the required condition
568592
CheckOpenRangeWithReturnedTuples(visible_tuple_locations);
569593

594+
// Add the tuple locations to the result vector in the order returned by
595+
// the index scan. We might end up reading the same tile group multiple
596+
// times. However, this is necessary to adhere to the ORDER BY clause
597+
oid_t current_tile_group_oid = INVALID_OID;
598+
std::vector<oid_t> tuples;
599+
570600
for (auto &visible_tuple_location : visible_tuple_locations) {
571-
visible_tuples[visible_tuple_location.block]
572-
.push_back(visible_tuple_location.offset);
573-
}
601+
if (current_tile_group_oid == INVALID_OID) {
602+
current_tile_group_oid = visible_tuple_location.block;
603+
}
604+
if (current_tile_group_oid == visible_tuple_location.block) {
605+
tuples.push_back(visible_tuple_location.offset);
606+
} else {
607+
// Since the tile_group_oids differ, fill in the current tile group
608+
// into the result vector
609+
auto &manager = catalog::Manager::GetInstance();
610+
auto tile_group = manager.GetTileGroup(current_tile_group_oid);
611+
std::unique_ptr<LogicalTile> logical_tile(LogicalTileFactory::GetTile());
612+
// Add relevant columns to logical tile
613+
logical_tile->AddColumns(tile_group, full_column_ids_);
614+
logical_tile->AddPositionList(std::move(tuples));
615+
if (column_ids_.size() != 0) {
616+
logical_tile->ProjectColumns(full_column_ids_, column_ids_);
617+
}
618+
result_.push_back(logical_tile.release());
574619

575-
// Construct a logical tile for each block
576-
for (auto tuples : visible_tuples) {
577-
auto &manager = catalog::Manager::GetInstance();
578-
auto tile_group = manager.GetTileGroup(tuples.first);
620+
// Change the current_tile_group_oid and add the current tuple
621+
tuples.clear();
622+
current_tile_group_oid = visible_tuple_location.block;
623+
tuples.push_back(visible_tuple_location.offset);
624+
}
625+
}
579626

627+
// Add the remaining tuples (if any) to the result vector
628+
if ((current_tile_group_oid != INVALID_OID) && (!tuples.empty())) {
629+
auto tile_group = manager.GetTileGroup(current_tile_group_oid);
580630
std::unique_ptr<LogicalTile> logical_tile(LogicalTileFactory::GetTile());
581631
// Add relevant columns to logical tile
582632
logical_tile->AddColumns(tile_group, full_column_ids_);
583-
logical_tile->AddPositionList(std::move(tuples.second));
633+
logical_tile->AddPositionList(std::move(tuples));
584634
if (column_ids_.size() != 0) {
585635
logical_tile->ProjectColumns(full_column_ids_, column_ids_);
586636
}
587-
588637
result_.push_back(logical_tile.release());
589638
}
590639

@@ -663,19 +712,6 @@ bool IndexScanExecutor::CheckKeyConditions(const ItemPointer &tuple_location) {
663712
// To make the procedure more uniform, we interpret IN as EQUAL
664713
// and NOT IN as NOT EQUAL, and react based on expression type below
665714
// accordingly
666-
/*if (expr_type == ExpressionType::COMPARE_IN) {
667-
bool bret = lhs.InList(rhs);
668-
669-
if (bret == true) {
670-
diff = VALUE_COMPARE_EQUAL;
671-
} else {
672-
diff = VALUE_COMPARE_NO_EQUAL;
673-
}
674-
} else {
675-
diff = lhs.Compare(rhs);
676-
}
677-
678-
LOG_TRACE("Difference : %d ", diff);*/
679715
if (lhs.CompareEquals(rhs) == CmpBool::TRUE) {
680716
switch (expr_type) {
681717
case ExpressionType::COMPARE_EQUAL:

src/include/threadpool/mono_queue_pool.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace threadpool {
2424
*/
2525
class MonoQueuePool {
2626
public:
27-
MonoQueuePool(int task_queue_size = 32, int worker_pool_size = 4)
27+
MonoQueuePool(uint32_t task_queue_size, uint32_t worker_pool_size)
2828
: task_queue_(task_queue_size),
2929
worker_pool_(worker_pool_size, &task_queue_),
3030
is_running_(false) {}
@@ -53,19 +53,18 @@ class MonoQueuePool {
5353
}
5454

5555
static MonoQueuePool &GetInstance() {
56-
int task_queue_size = settings::SettingsManager::GetBool(
56+
uint32_t task_queue_size = settings::SettingsManager::GetInt(
5757
settings::SettingId::monoqueue_task_queue_size);
58-
int worker_pool_size = settings::SettingsManager::GetBool(
58+
uint32_t worker_pool_size = settings::SettingsManager::GetInt(
5959
settings::SettingId::monoqueue_worker_pool_size);
60-
6160
static MonoQueuePool mono_queue_pool(task_queue_size, worker_pool_size);
6261
return mono_queue_pool;
6362
}
6463

6564
static MonoQueuePool &GetBrainInstance() {
66-
int task_queue_size = settings::SettingsManager::GetBool(
65+
uint32_t task_queue_size = settings::SettingsManager::GetInt(
6766
settings::SettingId::brain_task_queue_size);
68-
int worker_pool_size = settings::SettingsManager::GetBool(
67+
uint32_t worker_pool_size = settings::SettingsManager::GetInt(
6968
settings::SettingId::brain_worker_pool_size);
7069
static MonoQueuePool brain_queue_pool(task_queue_size, worker_pool_size);
7170
return brain_queue_pool;

src/storage/data_table.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,6 @@ bool DataTable::CheckForeignKeyConstraints(
773773

774774
// The foreign key constraints only refer to the primary key
775775
if (index->GetIndexType() == IndexConstraintType::PRIMARY_KEY) {
776-
LOG_INFO("BEGIN checking referred table");
777776

778777
std::vector<oid_t> key_attrs = foreign_key->GetSinkColumnIds();
779778
std::unique_ptr<catalog::Schema> foreign_key_schema(

test/optimizer/cost_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace test {
4242

4343
using namespace optimizer;
4444

45-
const int N_ROW = 100;
45+
// const int N_ROW = 100;
4646

4747
class CostTests : public PelotonTest {};
4848

test/sql/insert_sql_test.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,5 +523,52 @@ TEST_F(InsertSQLTests, InsertIntoSelectColumn) {
523523
txn_manager.CommitTransaction(txn);
524524
}
525525

526+
TEST_F(InsertSQLTests, UniqueColumn) {
527+
auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
528+
auto txn = txn_manager.BeginTransaction();
529+
catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn);
530+
txn_manager.CommitTransaction(txn);
531+
532+
std::string create_table("CREATE TABLE t (id INTEGER NOT NULL PRIMARY KEY,"
533+
"st VARCHAR(15) NOT NULL UNIQUE);");
534+
TestingSQLUtil::ExecuteSQLQuery(create_table);
535+
536+
ResultType result;
537+
std::vector<std::string> ref_result;
538+
std::string result_query = "select st from t;";
539+
540+
// Single row, should succeed
541+
std::string ins_query_1("INSERT INTO t VALUES (1, 'abc');");
542+
result = TestingSQLUtil::ExecuteSQLQuery(ins_query_1);
543+
EXPECT_EQ(result, ResultType::SUCCESS);
544+
ref_result.push_back("abc");
545+
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(result_query,
546+
ref_result,
547+
false);
548+
549+
// Second row, distinct from first, should succeed
550+
std::string ins_query_2("INSERT INTO t VALUES (2, 'def');");
551+
result = TestingSQLUtil::ExecuteSQLQuery(ins_query_2);
552+
EXPECT_EQ(result, ResultType::SUCCESS);
553+
ref_result.push_back("def");
554+
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(result_query,
555+
ref_result,
556+
false);
557+
558+
// Third row, non-unique value for string, should fail
559+
std::string ins_query_3("INSERT INTO t VALUES (3, 'abc');");
560+
result = TestingSQLUtil::ExecuteSQLQuery(ins_query_3);
561+
EXPECT_EQ(result, ResultType::ABORTED);
562+
// and the results returned should not include failed insert
563+
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(result_query,
564+
ref_result,
565+
false);
566+
567+
// free the database just created
568+
txn = txn_manager.BeginTransaction();
569+
catalog::Catalog::GetInstance()->DropDatabaseWithName(DEFAULT_DB_NAME, txn);
570+
txn_manager.CommitTransaction(txn);
571+
}
572+
526573
} // namespace test
527574
} // namespace peloton

0 commit comments

Comments
 (0)