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

Commit 27d3138

Browse files
Merge branch 'master' into join-reordering
2 parents 130890a + 828dd50 commit 27d3138

File tree

8 files changed

+59
-37
lines changed

8 files changed

+59
-37
lines changed

Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pipeline {
119119
// sh 'sudo /bin/bash -c "source ./script/installation/packages.sh"'
120120
// sh 'python ./script/validators/source_validator.py'
121121
// sh 'mkdir build'
122-
// sh 'cd build && cmake -DCMAKE_BUILD_TYPE=Debug -DCOVERALLS=False .. && make -j4'
122+
// sh 'cd build && PATH=/usr/lib64/llvm4.0/bin:$PATH cmake -DCMAKE_CXX_FLAGS="-isystem /usr/include/llvm4.0" -DCMAKE_BUILD_TYPE=Debug -DCOVERALLS=False .. && make -j4'
123123
// }
124124
// }
125125

@@ -129,7 +129,7 @@ pipeline {
129129
// sh 'sudo /bin/bash -c "source ./script/installation/packages.sh"'
130130
// sh 'python ./script/validators/source_validator.py'
131131
// sh 'mkdir build'
132-
// sh 'cd build && cmake -DCMAKE_BUILD_TYPE=Release -DCOVERALLS=False .. && make -j4'
132+
// sh 'cd build && PATH=/usr/lib64/llvm4.0/bin:$PATH cmake -DCMAKE_CXX_FLAGS="-isystem /usr/include/llvm4.0" -DCMAKE_BUILD_TYPE=Release -DCOVERALLS=False .. && make -j4'
133133
// }
134134
// }
135135

script/docker/fedora27/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN dnf -q -y install sudo
66

77
RUN /bin/bash -c "source ./peloton/script/installation/packages.sh"
88

9-
RUN mkdir /peloton/build && cd /peloton/build && cmake -DCMAKE_BUILD_TYPE=Release -DCOVERALLS=False .. && make -j4 && make install
9+
RUN mkdir /peloton/build && cd /peloton/build && PATH=/usr/lib64/llvm4.0/bin:$PATH cmake -DCMAKE_CXX_FLAGS="-isystem /usr/include/llvm4.0" -DCMAKE_BUILD_TYPE=Release -DCOVERALLS=False .. && make -j4 && make install
1010

1111
ENV PATH=$(BUILD_DIR)/bin:$PATH
1212
ENV LD_LIBRARY_PATH=$(BUILD_DIR)/lib:$LD_LIBRARY_PATH

script/docker/fedora27/Dockerfile-jenkins

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ RUN dnf -q -y install sudo clang
77
RUN /bin/bash -c "source ./peloton/script/installation/packages.sh"
88

99
RUN echo -n "Peloton Debug build with "; g++ --version | head -1
10-
RUN mkdir /peloton/build && cd /peloton/build && cmake -DCMAKE_BUILD_TYPE=Debug -DCOVERALLS=False .. && make -j4 && make install
10+
RUN mkdir /peloton/build && cd /peloton/build && PATH=/usr/lib64/llvm4.0/bin:$PATH cmake -DCMAKE_CXX_FLAGS="-isystem /usr/include/llvm4.0" -DCMAKE_BUILD_TYPE=Debug -DCOVERALLS=False .. && make -j4 && make install
1111

1212
RUN echo -n "Peloton Release build with "; g++ --version | head -1
13-
RUN rm -rf /peloton/build && mkdir /peloton/build && cd /peloton/build && cmake -DCMAKE_BUILD_TYPE=Release -DCOVERALLS=False .. && make -j4 && make install
13+
RUN rm -rf /peloton/build && mkdir /peloton/build && cd /peloton/build && PATH=/usr/lib64/llvm4.0/bin:$PATH cmake -DCMAKE_CXX_FLAGS="-isystem /usr/include/llvm4.0" -DCMAKE_BUILD_TYPE=Release -DCOVERALLS=False .. && make -j4 && make install
1414

1515
RUN echo -n "Peloton Debug build with "; clang++ --version | head -1
16-
RUN rm -rf /peloton/build && mkdir /peloton/build && cd /peloton/build && CC=clang CXX=clang++ cmake -DCMAKE_BUILD_TYPE=Debug -DCOVERALLS=False .. && make -j4 && make install
16+
RUN rm -rf /peloton/build && mkdir /peloton/build && cd /peloton/build && PATH=/usr/lib64/llvm4.0/bin:$PATH CC=clang CXX=clang++ cmake -DCMAKE_CXX_FLAGS="-isystem /usr/include/llvm4.0" -DCMAKE_BUILD_TYPE=Debug -DCOVERALLS=False .. && make -j4 && make install
1717

1818
RUN echo -n "Peloton Release build with "; clang++ --version | head -1
19-
RUN rm -rf /peloton/build && mkdir /peloton/build && cd /peloton/build && CC=clang CXX=clang++ cmake -DCMAKE_BUILD_TYPE=Release -DCOVERALLS=False .. && make -j4 && make install
19+
RUN rm -rf /peloton/build && mkdir /peloton/build && cd /peloton/build && PATH=/usr/lib64/llvm4.0/bin:$PATH CC=clang CXX=clang++ cmake -DCMAKE_CXX_FLAGS="-isystem /usr/include/llvm4.0" -DCMAKE_BUILD_TYPE=Release -DCOVERALLS=False .. && make -j4 && make install

script/installation/packages.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ elif [ "$DISTRO" = "DEBIAN OS" ]; then
136136
## FEDORA
137137
## ------------------------------------------------
138138
elif [[ "$DISTRO" == *"FEDORA"* ]]; then
139+
case $DISTRO_VER in
140+
26) LLVM="llvm";;
141+
*) LLVM="llvm4.0";;
142+
esac
143+
139144
sudo dnf -q install -y \
140145
git \
141146
gcc-c++ \
@@ -153,9 +158,9 @@ elif [[ "$DISTRO" == *"FEDORA"* ]]; then
153158
lcov \
154159
libpqxx-devel \
155160
libpqxx \
156-
llvm \
157-
llvm-devel \
158-
llvm-static \
161+
${LLVM} \
162+
${LLVM}-devel \
163+
${LLVM}-static \
159164
libedit-devel \
160165
postgresql \
161166
libatomic

src/binder/bind_node_visitor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ void BindNodeVisitor::Visit(parser::CreateStatement *node) {
175175
}
176176
void BindNodeVisitor::Visit(parser::InsertStatement *node) {
177177
node->TryBindDatabaseName(default_database_name_);
178+
context_ = std::make_shared<BinderContext>(nullptr);
179+
context_->AddRegularTable(node->GetDatabaseName(), node->GetTableName(),
180+
node->GetTableName(), txn_);
178181
if (node->select != nullptr) {
179182
node->select->Accept(this);
180183
}

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) {
@@ -199,7 +199,7 @@ class Exception : public std::runtime_error {
199199
}
200200
}
201201

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

204204
private:
205205
// type
@@ -432,8 +432,9 @@ class ConnectionException : public Exception {
432432
class NetworkProcessException : public Exception {
433433
NetworkProcessException() = delete;
434434

435-
public:
436-
NetworkProcessException(std::string msg) : Exception(ExceptionType::NETWORK, msg) {}
435+
public:
436+
NetworkProcessException(std::string msg)
437+
: Exception(ExceptionType::NETWORK, msg) {}
437438
};
438439

439440
class SettingsException : public Exception {

src/optimizer/query_to_operator_transformer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ void QueryToOperatorTransformer::Visit(parser::InsertStatement *op) {
231231
catalog::Catalog::GetInstance()
232232
->GetDatabaseObject(op->GetDatabaseName(), txn_)
233233
->GetTableObject(op->GetTableName());
234+
234235
if (op->type == InsertType::SELECT) {
235236
auto insert_expr = std::make_shared<OperatorExpression>(
236237
LogicalInsertSelect::make(target_table));

test/sql/insert_sql_test.cpp

Lines changed: 33 additions & 21 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,5 +567,20 @@ TEST_F(InsertSQLTests, UniqueColumn) {
570567
txn_manager.CommitTransaction(txn);
571568
}
572569

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+
std::unique_ptr<optimizer::AbstractOptimizer> optimizer(
577+
new optimizer::Optimizer());
578+
// Insert an int into a non-existent table.
579+
std::string query("INSERT INTO NonExistentTable VALUES(3);");
580+
txn = txn_manager.BeginTransaction();
581+
EXPECT_THROW(TestingSQLUtil::GeneratePlanWithOptimizer(optimizer, query, txn),
582+
peloton::CatalogException);
583+
}
584+
573585
} // namespace test
574586
} // namespace peloton

0 commit comments

Comments
 (0)