@@ -55,17 +55,17 @@ InsertPlan::InsertPlan(storage::DataTable *table,
55
55
PELOTON_ASSERT (values.size () <= schema_col_count);
56
56
// uint32_t param_idx = 0;
57
57
for (uint32_t column_id = 0 ; column_id < values.size (); column_id++) {
58
-
58
+
59
59
auto &exp = values[column_id];
60
- auto exp_ptr = exp.get ();
61
- auto ret_bool = ProcessValueExpr (exp_ptr, column_id);
62
- // there is no column specification, so we have a
63
- // direct mapping between schema cols and the value vector
64
- schema_to_insert_[column_id].in_insert_cols = true ;
65
- schema_to_insert_[column_id].val_idx = column_id;
66
- if (ret_bool == true ) {
67
- is_prepared_stmt = true ;
68
- }
60
+ auto exp_ptr = exp.get ();
61
+ auto ret_bool = ProcessValueExpr (exp_ptr, column_id);
62
+ // there is no column specification, so we have a
63
+ // direct mapping between schema cols and the value vector
64
+ schema_to_insert_[column_id].in_insert_cols = true ;
65
+ schema_to_insert_[column_id].val_idx = column_id;
66
+ if (ret_bool == true ) {
67
+ is_prepared_stmt = true ;
68
+ }
69
69
}
70
70
}
71
71
} else {
@@ -80,41 +80,41 @@ InsertPlan::InsertPlan(storage::DataTable *table,
80
80
PELOTON_ASSERT (values.size () <= schema_col_count);
81
81
82
82
for (uint32_t idx = 0 ; idx < schema_col_count; idx++) {
83
- if (schema_to_insert_[idx].in_insert_cols ) {
84
- // this schema column is present in the insert columns spec.
85
- // get index into values
86
- auto val_idx = schema_to_insert_[idx].val_idx ;
87
- auto &exp = values[val_idx];
88
- auto exp_ptr = exp.get ();
89
- bool ret_bool = ProcessValueExpr (exp_ptr, idx);
90
- if (ret_bool) {
91
- is_prepared_stmt = true ;
92
- }
93
- } else {
94
- // schema column not present in insert columns spec. Set
95
- // column to its default value
96
- SetDefaultValue (idx);
97
- }
83
+ if (schema_to_insert_[idx].in_insert_cols ) {
84
+ // this schema column is present in the insert columns spec.
85
+ // get index into values
86
+ auto val_idx = schema_to_insert_[idx].val_idx ;
87
+ auto &exp = values[val_idx];
88
+ auto exp_ptr = exp.get ();
89
+ bool ret_bool = ProcessValueExpr (exp_ptr, idx);
90
+ if (ret_bool) {
91
+ is_prepared_stmt = true ;
92
+ }
93
+ } else {
94
+ // schema column not present in insert columns spec. Set
95
+ // column to its default value
96
+ SetDefaultValue (idx);
97
+ }
98
98
}
99
99
100
100
if (is_prepared_stmt) {
101
- // Adjust indexes into values. When constants are present in the
102
- // value tuple spec., the value vector supplied by the prepared
103
- // statement when SetParameterValues is called, will be smaller.
104
- // It will not include any of the constants.
105
- // Adjust the mapping from schema cols -> values vector to exclude
106
- // the constant columns. If there are no constants, this is a no-op.
107
- uint32_t adjust = 0 ;
108
- for (uint32_t idx=0 ; idx < columns->size (); idx++) {
109
- uint32_t stov_idx = insert_to_schema_[idx];
110
- if (schema_to_insert_[stov_idx].set_value ) {
111
- // constant, not present in PS values
112
- adjust++;
113
- } else {
114
- // adjust the index
115
- schema_to_insert_[stov_idx].val_idx -= adjust;
116
- }
117
- }
101
+ // Adjust indexes into values. When constants are present in the
102
+ // value tuple spec., the value vector supplied by the prepared
103
+ // statement when SetParameterValues is called, will be smaller.
104
+ // It will not include any of the constants.
105
+ // Adjust the mapping from schema cols -> values vector to exclude
106
+ // the constant columns. If there are no constants, this is a no-op.
107
+ uint32_t adjust = 0 ;
108
+ for (uint32_t idx=0 ; idx < columns->size (); idx++) {
109
+ uint32_t stov_idx = insert_to_schema_[idx];
110
+ if (schema_to_insert_[stov_idx].set_value ) {
111
+ // constant, not present in PS values
112
+ adjust++;
113
+ } else {
114
+ // adjust the index
115
+ schema_to_insert_[stov_idx].val_idx -= adjust;
116
+ }
117
+ }
118
118
}
119
119
}
120
120
}
@@ -127,8 +127,8 @@ InsertPlan::InsertPlan(storage::DataTable *table,
127
127
}
128
128
129
129
bool InsertPlan::FindSchemaColIndex (std::string col_name,
130
- const std::vector<catalog::Column> &tbl_columns,
131
- uint32_t &index) {
130
+ const std::vector<catalog::Column> &tbl_columns,
131
+ uint32_t &index) {
132
132
for (auto tcol = tbl_columns.begin (); tcol != tbl_columns.end (); tcol++) {
133
133
if (tcol->GetName () == col_name) {
134
134
index = std::distance (tbl_columns.begin (), tcol);
@@ -152,7 +152,7 @@ void InsertPlan::ProcessColumnSpec(const std::vector<std::string> *columns) {
152
152
bool found_col = FindSchemaColIndex (col_name, table_columns, idx);
153
153
if (not found_col) {
154
154
throw Exception (" column " + col_name + " not in table " +
155
- target_table_->GetName () + " columns" );
155
+ target_table_->GetName () + " columns" );
156
156
}
157
157
// we have values for this column
158
158
schema_to_insert_[idx].in_insert_cols = true ;
@@ -164,7 +164,7 @@ void InsertPlan::ProcessColumnSpec(const std::vector<std::string> *columns) {
164
164
}
165
165
166
166
bool InsertPlan::ProcessValueExpr (expression::AbstractExpression *expr,
167
- uint32_t schema_idx) {
167
+ uint32_t schema_idx) {
168
168
auto type = schema_to_insert_[schema_idx].type ;
169
169
170
170
if (expr == nullptr ) {
@@ -183,7 +183,7 @@ bool InsertPlan::ProcessValueExpr(expression::AbstractExpression *expr,
183
183
return false ;
184
184
} else {
185
185
PELOTON_ASSERT (expr->GetExpressionType () ==
186
- ExpressionType::VALUE_PARAMETER);
186
+ ExpressionType::VALUE_PARAMETER);
187
187
return true ;
188
188
}
189
189
return false ;
0 commit comments