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

Commit b788114

Browse files
schedutronapavlo
authored andcommitted
Run formatter.py
1 parent a72f2e9 commit b788114

File tree

2 files changed

+52
-54
lines changed

2 files changed

+52
-54
lines changed

src/include/common/exception.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ enum class ExceptionType {
5757
CONNECTION = 21, // connection related
5858
SYNTAX = 22, // syntax related
5959
SETTINGS = 23, // settings related
60-
BINDER = 24, // settings related
60+
BINDER = 24, // settings related
6161
NETWORK = 25
6262
};
6363

@@ -71,8 +71,8 @@ class Exception : public std::runtime_error {
7171
Exception(ExceptionType exception_type, std::string message)
7272
: std::runtime_error(message), type(exception_type) {
7373
exception_message_ = "Exception Type :: " +
74-
ExceptionTypeToString(exception_type) +
75-
"\nMessage :: " + message;
74+
ExceptionTypeToString(exception_type) +
75+
"\nMessage :: " + message;
7676
}
7777

7878
std::string ExceptionTypeToString(ExceptionType type) {
@@ -201,7 +201,7 @@ class Exception : public std::runtime_error {
201201
}
202202
}
203203

204-
friend std::ostream& operator<<(std::ostream& os, const Exception& e);
204+
friend std::ostream &operator<<(std::ostream &os, const Exception &e);
205205

206206
private:
207207
// type
@@ -434,8 +434,9 @@ class ConnectionException : public Exception {
434434
class NetworkProcessException : public Exception {
435435
NetworkProcessException() = delete;
436436

437-
public:
438-
NetworkProcessException(std::string msg) : Exception(ExceptionType::NETWORK, msg) {}
437+
public:
438+
NetworkProcessException(std::string msg)
439+
: Exception(ExceptionType::NETWORK, msg) {}
439440
};
440441

441442
class SettingsException : public Exception {

test/sql/insert_sql_test.cpp

Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,12 @@ void CreateAndLoadTable4() {
6363
"i CHAR, j VARCHAR, k VARBINARY, l BOOLEAN);");
6464

6565
// Insert tuples into table
66-
TestingSQLUtil::ExecuteSQLQuery("INSERT INTO test4 VALUES "
66+
TestingSQLUtil::ExecuteSQLQuery(
67+
"INSERT INTO test4 VALUES "
6768
"(1, 2, 3, 4, 5.1, 6.1, '2017-10-10 00:00:00-00', "
6869
"'A', 'a', '1', 'true');");
69-
TestingSQLUtil::ExecuteSQLQuery("INSERT INTO test4 VALUES "
70+
TestingSQLUtil::ExecuteSQLQuery(
71+
"INSERT INTO test4 VALUES "
7072
"(11, 12, 13, 14, 15.1, 16.1, '2017-10-11 00:00:00-00', "
7173
"'B', 'b', '2', 'false');");
7274
}
@@ -81,8 +83,7 @@ void CreateAndLoadTable5() {
8183

8284
void CreateAndLoadTable6() {
8385
// Create a table first
84-
TestingSQLUtil::ExecuteSQLQuery(
85-
"CREATE TABLE test6(a INT, b INT, c INT);");
86+
TestingSQLUtil::ExecuteSQLQuery("CREATE TABLE test6(a INT, b INT, c INT);");
8687

8788
// Insert tuples into table
8889
TestingSQLUtil::ExecuteSQLQuery("INSERT INTO test6 VALUES (1, 22, 333);");
@@ -93,8 +94,7 @@ void CreateAndLoadTable6() {
9394

9495
void CreateAndLoadTable7() {
9596
// Create a table first
96-
TestingSQLUtil::ExecuteSQLQuery(
97-
"CREATE TABLE test7(a INT, b INT, c INT);");
97+
TestingSQLUtil::ExecuteSQLQuery("CREATE TABLE test7(a INT, b INT, c INT);");
9898

9999
// Insert tuples into table
100100
TestingSQLUtil::ExecuteSQLQuery("INSERT INTO test7 VALUES (99, 5, 888);");
@@ -103,7 +103,6 @@ void CreateAndLoadTable7() {
103103
TestingSQLUtil::ExecuteSQLQuery("INSERT INTO test7 VALUES (55, 8, 999);");
104104
}
105105

106-
107106
TEST_F(InsertSQLTests, InsertOneValue) {
108107
auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
109108
auto txn = txn_manager.BeginTransaction();
@@ -258,12 +257,12 @@ TEST_F(InsertSQLTests, InsertTooLargeVarchar) {
258257
new optimizer::Optimizer());
259258

260259
std::string query("INSERT INTO test3 VALUES(1, 'abcd', 'abcdefghij');");
261-
//std::string query("INSERT INTO test3 VALUES(1, 'abcd', 'abcdefghijk');");
260+
// std::string query("INSERT INTO test3 VALUES(1, 'abcd', 'abcdefghijk');");
262261

263262
txn = txn_manager.BeginTransaction();
264-
// This should be re-enabled when the check is properly done in catalog
263+
// This should be re-enabled when the check is properly done in catalog
265264
// It used to be done at the insert query level
266-
//EXPECT_THROW(TestingSQLUtil::GeneratePlanWithOptimizer(optimizer, query,
265+
// EXPECT_THROW(TestingSQLUtil::GeneratePlanWithOptimizer(optimizer, query,
267266
// txn, peloton::Exception);
268267
auto plan = TestingSQLUtil::GeneratePlanWithOptimizer(optimizer, query, txn);
269268
EXPECT_EQ(plan->GetPlanNodeType(), PlanNodeType::INSERT);
@@ -402,7 +401,7 @@ TEST_F(InsertSQLTests, InsertIntoSelectSimpleAllType) {
402401
EXPECT_EQ("5.1", TestingSQLUtil::GetResultValueAsString(result, 4));
403402
EXPECT_EQ("6.1", TestingSQLUtil::GetResultValueAsString(result, 5));
404403
EXPECT_EQ("2017-10-10 00:00:00.000000+00",
405-
TestingSQLUtil::GetResultValueAsString(result, 6));
404+
TestingSQLUtil::GetResultValueAsString(result, 6));
406405
EXPECT_EQ("A", TestingSQLUtil::GetResultValueAsString(result, 7));
407406
EXPECT_EQ("a", TestingSQLUtil::GetResultValueAsString(result, 8));
408407
EXPECT_EQ('1', TestingSQLUtil::GetResultValueAsString(result, 9).at(0));
@@ -419,7 +418,7 @@ TEST_F(InsertSQLTests, InsertIntoSelectSimpleAllType) {
419418
EXPECT_EQ("5.1", TestingSQLUtil::GetResultValueAsString(result, 4));
420419
EXPECT_EQ("6.1", TestingSQLUtil::GetResultValueAsString(result, 5));
421420
EXPECT_EQ("2017-10-10 00:00:00.000000+00",
422-
TestingSQLUtil::GetResultValueAsString(result, 6));
421+
TestingSQLUtil::GetResultValueAsString(result, 6));
423422
EXPECT_EQ("A", TestingSQLUtil::GetResultValueAsString(result, 7));
424423
EXPECT_EQ("a", TestingSQLUtil::GetResultValueAsString(result, 8));
425424
EXPECT_EQ('1', TestingSQLUtil::GetResultValueAsString(result, 9).at(0));
@@ -436,7 +435,7 @@ TEST_F(InsertSQLTests, InsertIntoSelectSimpleAllType) {
436435
EXPECT_EQ("15.1", TestingSQLUtil::GetResultValueAsString(result, 4));
437436
EXPECT_EQ("16.1", TestingSQLUtil::GetResultValueAsString(result, 5));
438437
EXPECT_EQ("2017-10-11 00:00:00.000000+00",
439-
TestingSQLUtil::GetResultValueAsString(result, 6));
438+
TestingSQLUtil::GetResultValueAsString(result, 6));
440439
EXPECT_EQ("B", TestingSQLUtil::GetResultValueAsString(result, 7));
441440
EXPECT_EQ("b", TestingSQLUtil::GetResultValueAsString(result, 8));
442441
EXPECT_EQ('2', TestingSQLUtil::GetResultValueAsString(result, 9).at(0));
@@ -529,8 +528,9 @@ TEST_F(InsertSQLTests, UniqueColumn) {
529528
catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn);
530529
txn_manager.CommitTransaction(txn);
531530

532-
std::string create_table("CREATE TABLE t (id INTEGER NOT NULL PRIMARY KEY,"
533-
"st VARCHAR(15) NOT NULL UNIQUE);");
531+
std::string create_table(
532+
"CREATE TABLE t (id INTEGER NOT NULL PRIMARY KEY,"
533+
"st VARCHAR(15) NOT NULL UNIQUE);");
534534
TestingSQLUtil::ExecuteSQLQuery(create_table);
535535

536536
ResultType result;
@@ -542,26 +542,23 @@ TEST_F(InsertSQLTests, UniqueColumn) {
542542
result = TestingSQLUtil::ExecuteSQLQuery(ins_query_1);
543543
EXPECT_EQ(result, ResultType::SUCCESS);
544544
ref_result.push_back("abc");
545-
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(result_query,
546-
ref_result,
545+
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(result_query, ref_result,
547546
false);
548547

549548
// Second row, distinct from first, should succeed
550549
std::string ins_query_2("INSERT INTO t VALUES (2, 'def');");
551550
result = TestingSQLUtil::ExecuteSQLQuery(ins_query_2);
552551
EXPECT_EQ(result, ResultType::SUCCESS);
553552
ref_result.push_back("def");
554-
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(result_query,
555-
ref_result,
553+
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(result_query, ref_result,
556554
false);
557555

558556
// Third row, non-unique value for string, should fail
559557
std::string ins_query_3("INSERT INTO t VALUES (3, 'abc');");
560558
result = TestingSQLUtil::ExecuteSQLQuery(ins_query_3);
561559
EXPECT_EQ(result, ResultType::ABORTED);
562560
// and the results returned should not include failed insert
563-
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(result_query,
564-
ref_result,
561+
TestingSQLUtil::ExecuteSQLQueryAndCheckResult(result_query, ref_result,
565562
false);
566563

567564
// free the database just created
@@ -570,33 +567,33 @@ TEST_F(InsertSQLTests, UniqueColumn) {
570567
txn_manager.CommitTransaction(txn);
571568
}
572569

573-
TEST_F(InsertSQLTests, NonExistentTable){
574-
auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
575-
auto txn = txn_manager.BeginTransaction();
576-
catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn);
577-
txn_manager.CommitTransaction(txn);
578-
std::string error_message;
579-
int rows_changed;
580-
std::unique_ptr<optimizer::AbstractOptimizer> optimizer(
581-
new optimizer::Optimizer());
582-
583-
rows_changed = 0;
584-
EXPECT_THROW({
585-
try {
586-
// Insert an int into a non-existent table.
587-
std::string query("INSERT INTO NotExistTestTable VALUES(3);");
588-
txn = txn_manager.BeginTransaction();
589-
auto plan = TestingSQLUtil::GeneratePlanWithOptimizer(optimizer, query, txn);
590-
EXPECT_EQ(plan->GetPlanNodeType(), PlanNodeType::INSERT);
591-
txn_manager.CommitTransaction(txn);
592-
} catch (peloton::Exception &ex) {
593-
EXPECT_EQ(ExceptionType::CATALOG, ex.GetType());
594-
EXPECT_STREQ("Table NotExistTestTable is not found",
595-
ex.what());
596-
throw peloton::CatalogException(ex.what());
597-
}
598-
}, peloton::CatalogException);
599-
EXPECT_EQ(0, rows_changed);
570+
TEST_F(InsertSQLTests, NonExistentTable) {
571+
auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
572+
auto txn = txn_manager.BeginTransaction();
573+
catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn);
574+
txn_manager.CommitTransaction(txn);
575+
std::string error_message;
576+
int rows_changed;
577+
std::unique_ptr<optimizer::AbstractOptimizer> optimizer(
578+
new optimizer::Optimizer());
579+
580+
rows_changed = 0;
581+
EXPECT_THROW({
582+
try {
583+
// Insert an int into a non-existent table.
584+
std::string query("INSERT INTO NotExistTestTable VALUES(3);");
585+
txn = txn_manager.BeginTransaction();
586+
auto plan =
587+
TestingSQLUtil::GeneratePlanWithOptimizer(optimizer, query, txn);
588+
EXPECT_EQ(plan->GetPlanNodeType(), PlanNodeType::INSERT);
589+
txn_manager.CommitTransaction(txn);
590+
} catch (peloton::Exception &ex) {
591+
EXPECT_EQ(ExceptionType::CATALOG, ex.GetType());
592+
EXPECT_STREQ("Table NotExistTestTable is not found", ex.what());
593+
throw peloton::CatalogException(ex.what());
594+
}
595+
}, peloton::CatalogException);
596+
EXPECT_EQ(0, rows_changed);
600597
}
601598

602599
} // namespace test

0 commit comments

Comments
 (0)