@@ -54,12 +54,13 @@ TEST_F(ConstraintsTests, NOTNULLTest) {
54
54
// Set all of the columns to be NOT NULL
55
55
std::vector<std::vector<catalog::Constraint>> constraints;
56
56
for (int i = 0 ; i < CONSTRAINTS_NUM_COLS; i++) {
57
- constraints.push_back ({ catalog::Constraint (ConstraintType::NOTNULL,
58
- " notnull_constraint" ) });
57
+ constraints.push_back (
58
+ { catalog::Constraint (ConstraintType::NOTNULL, " notnull_constraint" )});
59
59
}
60
60
std::vector<catalog::MultiConstraint> multi_constraints;
61
61
storage::DataTable *data_table =
62
- TestingConstraintsUtil::CreateAndPopulateTable (constraints, multi_constraints);
62
+ TestingConstraintsUtil::CreateAndPopulateTable (constraints,
63
+ multi_constraints);
63
64
64
65
// Bootstrap
65
66
auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance ();
@@ -68,14 +69,12 @@ TEST_F(ConstraintsTests, NOTNULLTest) {
68
69
type::ValueFactory::GetIntegerValue (1 ),
69
70
type::ValueFactory::GetIntegerValue (22 ),
70
71
type::ValueFactory::GetDecimalValue (3.33 ),
71
- type::ValueFactory::GetVarcharValue (" 4444" )
72
- };
72
+ type::ValueFactory::GetVarcharValue (" 4444" )};
73
73
std::vector<type::Value> null_values = {
74
74
type::ValueFactory::GetNullValueByType (type::TypeId::INTEGER),
75
75
type::ValueFactory::GetNullValueByType (type::TypeId::INTEGER),
76
76
type::ValueFactory::GetNullValueByType (type::TypeId::DECIMAL),
77
- type::ValueFactory::GetNullValueByType (type::TypeId::VARCHAR)
78
- };
77
+ type::ValueFactory::GetNullValueByType (type::TypeId::VARCHAR)};
79
78
80
79
// Test1: Insert a tuple with column that satisfies the requirement
81
80
auto txn = txn_manager.BeginTransaction ();
@@ -103,8 +102,8 @@ TEST_F(ConstraintsTests, NOTNULLTest) {
103
102
}
104
103
EXPECT_TRUE (hasException);
105
104
txn_manager.CommitTransaction (txn);
106
- } // FOR
107
-
105
+ } // FOR
106
+
108
107
// free the database just created
109
108
txn = txn_manager.BeginTransaction ();
110
109
catalog::Catalog::GetInstance ()->DropDatabaseWithName (DEFAULT_DB_NAME, txn);
@@ -120,22 +119,23 @@ TEST_F(ConstraintsTests, DEFAULTTESTTest) {
120
119
// COL_A
121
120
if (i == 0 ) {
122
121
constraints.push_back (
123
- { catalog::Constraint (ConstraintType::PRIMARY, " pkey" ) });
122
+ {catalog::Constraint (ConstraintType::PRIMARY, " pkey" )});
124
123
}
125
124
// COL_B
126
125
else if (i == 1 ) {
127
126
catalog::Constraint default_const (ConstraintType::DEFAULT, " default" );
128
127
default_const.addDefaultValue (
129
128
type::ValueFactory::GetIntegerValue (DEFAULT_VALUE));
130
- constraints.push_back ({ });
129
+ constraints.push_back ({});
131
130
}
132
131
// COL_C + COL_D
133
132
else {
134
- constraints.push_back ({ });
133
+ constraints.push_back ({});
135
134
}
136
135
}
137
136
std::vector<catalog::MultiConstraint> multi_constraints;
138
- TestingConstraintsUtil::CreateAndPopulateTable (constraints, multi_constraints);
137
+ TestingConstraintsUtil::CreateAndPopulateTable (constraints,
138
+ multi_constraints);
139
139
140
140
// Bootstrap
141
141
std::vector<ResultValue> result;
@@ -146,17 +146,17 @@ TEST_F(ConstraintsTests, DEFAULTTESTTest) {
146
146
// Test1: Insert a tuple without the second column defined
147
147
// It should get set with the default value
148
148
std::string sql = StringUtil::Format (
149
- " INSERT INTO %s (col_a, col_c, col_d) "
150
- " VALUES (9999, 2.2, 'xxx');" , CONSTRAINTS_TEST_TABLE);
151
- auto status = TestingSQLUtil::ExecuteSQLQuery (
152
- sql, result, tuple_descriptor, rows_affected, error_message
153
- );
149
+ " INSERT INTO %s (col_a, col_c, col_d) "
150
+ " VALUES (9999, 2.2, 'xxx');" ,
151
+ CONSTRAINTS_TEST_TABLE);
152
+ auto status = TestingSQLUtil::ExecuteSQLQuery ( sql, result, tuple_descriptor,
153
+ rows_affected, error_message );
154
154
EXPECT_EQ (ResultType::SUCCESS, status);
155
155
156
156
sql = StringUtil::Format (" SELECT col_d FROM %s WHERE col_a = 9999" ,
157
157
CONSTRAINTS_TEST_TABLE);
158
- status = TestingSQLUtil::ExecuteSQLQuery (
159
- sql, result, tuple_descriptor, rows_affected, error_message);
158
+ status = TestingSQLUtil::ExecuteSQLQuery (sql, result, tuple_descriptor,
159
+ rows_affected, error_message);
160
160
EXPECT_EQ (ResultType::SUCCESS, status);
161
161
std::string resultStr = TestingSQLUtil::GetResultValueAsString (result, 0 );
162
162
LOG_INFO (" OUTPUT:\n %s" , resultStr.c_str ());
@@ -179,7 +179,8 @@ TEST_F(ConstraintsTests, CHECKTest) {
179
179
type::Value tmp_value = type::ValueFactory::GetIntegerValue (0 );
180
180
constraints.AddCheck (ExpressionType::COMPARE_GREATERTHAN, tmp_value);
181
181
column1.AddConstraint (constraints);
182
- LOG_DEBUG (" %s %s" , peloton::DOUBLE_STAR.c_str (), constraints.GetInfo ().c_str ());
182
+ LOG_DEBUG (" %s %s" , peloton::DOUBLE_STAR.c_str (),
183
+ constraints.GetInfo ().c_str ());
183
184
catalog::Schema *table_schema = new catalog::Schema ({column1});
184
185
std::string table_name (" TEST_TABLE" );
185
186
bool own_schema = true ;
@@ -230,7 +231,8 @@ TEST_F(ConstraintsTests, UNIQUETest) {
230
231
231
232
auto constraints = catalog::Constraint (ConstraintType::UNIQUE, " unique1" );
232
233
column1.AddConstraint (constraints);
233
- LOG_DEBUG (" %s %s" , peloton::DOUBLE_STAR.c_str (), constraints.GetInfo ().c_str ());
234
+ LOG_DEBUG (" %s %s" , peloton::DOUBLE_STAR.c_str (),
235
+ constraints.GetInfo ().c_str ());
234
236
std::unique_ptr<catalog::Schema> table_schema (
235
237
new catalog::Schema ({column1, column2}));
236
238
std::string table_name (" TEST_TABLE" );
@@ -288,7 +290,7 @@ TEST_F(ConstraintsTests, UNIQUETest) {
288
290
}
289
291
#endif
290
292
291
- // TEST_F(ConstraintsTests, MULTIUNIQUETest) {
293
+ // TEST_F(ConstraintsTests, MULTIUNIQUETest) {
292
294
// auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
293
295
// auto catalog = catalog::Catalog::GetInstance();
294
296
// auto txn = txn_manager.BeginTransaction();
@@ -368,7 +370,7 @@ TEST_F(ConstraintsTests, UNIQUETest) {
368
370
// txn_manager.CommitTransaction(txn);
369
371
// }
370
372
371
- // TEST_F(ConstraintsTests, ForeignKeySingleInsertTest) {
373
+ // TEST_F(ConstraintsTests, ForeignKeySingleInsertTest) {
372
374
// // First, initial 2 tables like following
373
375
// // TABLE A -- src table TABLE B -- sink table
374
376
// // a int(primary, ref B) b int b int(primary) c int
@@ -393,7 +395,8 @@ TEST_F(ConstraintsTests, UNIQUETest) {
393
395
//
394
396
// auto constraints = catalog::Constraint(ConstraintType::PRIMARY, "primary1");
395
397
// column1.AddConstraint(constraints);
396
- // LOG_DEBUG("%s %s", peloton::DOUBLE_STAR.c_str(), constraints.GetInfo().c_str());
398
+ // LOG_DEBUG("%s %s", peloton::DOUBLE_STAR.c_str(),
399
+ // constraints.GetInfo().c_str());
397
400
// std::unique_ptr<catalog::Schema> tableA_schema(
398
401
// new catalog::Schema({column1, column2}));
399
402
//
@@ -413,8 +416,10 @@ TEST_F(ConstraintsTests, UNIQUETest) {
413
416
// auto table_b = catalog->GetTableWithName(db_name, table_b_name);
414
417
//
415
418
// oid_t sink_table_id = table_b->GetOid();
416
- // std::vector<oid_t> sink_col_ids = { table_b->GetSchema()->GetColumnID("b") };
417
- // std::vector<oid_t> source_col_ids = { table_a->GetSchema()->GetColumnID("a") };
419
+ // std::vector<oid_t> sink_col_ids = { table_b->GetSchema()->GetColumnID("b")
420
+ // };
421
+ // std::vector<oid_t> source_col_ids = { table_a->GetSchema()->GetColumnID("a")
422
+ // };
418
423
// catalog::ForeignKey *foreign_key = new catalog::ForeignKey(
419
424
// sink_table_id, sink_col_ids, source_col_ids,
420
425
// FKConstrActionType::NOACTION,
@@ -463,7 +468,7 @@ TEST_F(ConstraintsTests, UNIQUETest) {
463
468
// delete foreign_key;
464
469
// }
465
470
466
- // TEST_F(ConstraintsTests, ForeignKeyMultiInsertTest) {
471
+ // TEST_F(ConstraintsTests, ForeignKeyMultiInsertTest) {
467
472
// // First, initial 2 tables like following
468
473
// // TABLE A -- src table TABLE B -- sink table
469
474
// // a int(primary, ref B) b int b int(primary) c int
@@ -498,7 +503,8 @@ TEST_F(ConstraintsTests, UNIQUETest) {
498
503
// cols.push_back(0);
499
504
// cols.push_back(1);
500
505
// auto mc =
501
- // catalog::MultiConstraint(ConstraintType::PRIMARY, "multiprimary1", cols);
506
+ // catalog::MultiConstraint(ConstraintType::PRIMARY, "multiprimary1",
507
+ // cols);
502
508
// LOG_DEBUG("%s MULTI CONSTRAINTS %s %s", peloton::DOUBLE_STAR.c_str(),
503
509
// peloton::DOUBLE_STAR.c_str(), mc.GetInfo().c_str());
504
510
//
@@ -514,8 +520,10 @@ TEST_F(ConstraintsTests, UNIQUETest) {
514
520
//
515
521
// // Create foreign key tableA.B -> tableB.B
516
522
// oid_t sink_table_id = table_b->GetOid();
517
- // std::vector<oid_t> sink_col_ids = { table_b->GetSchema()->GetColumnID("b") };
518
- // std::vector<oid_t> source_col_ids = { table_a->GetSchema()->GetColumnID("b") };
523
+ // std::vector<oid_t> sink_col_ids = { table_b->GetSchema()->GetColumnID("b")
524
+ // };
525
+ // std::vector<oid_t> source_col_ids = { table_a->GetSchema()->GetColumnID("b")
526
+ // };
519
527
// catalog::ForeignKey *foreign_key = new catalog::ForeignKey(
520
528
// sink_table_id, sink_col_ids, source_col_ids,
521
529
// FKConstrActionType::RESTRICT,
0 commit comments