|
10 | 10 | //
|
11 | 11 | //===----------------------------------------------------------------------===//
|
12 | 12 |
|
| 13 | +#include <include/codegen/type/varchar_type.h> |
13 | 14 | #include "codegen/lang/if.h"
|
14 | 15 | #include "codegen/proxy/storage_manager_proxy.h"
|
15 | 16 | #include "codegen/proxy/target_proxy.h"
|
@@ -41,13 +42,14 @@ UpdateTranslator::UpdateTranslator(const planner::UpdatePlan &update_plan,
|
41 | 42 | UpdaterProxy::GetType(GetCodeGen()));
|
42 | 43 | }
|
43 | 44 |
|
44 |
| -bool IsTarget(const TargetList &target_list, uint32_t index) { |
45 |
| - for (const auto &target : target_list) { |
46 |
| - if (target.first == index) { |
47 |
| - return true; |
48 |
| - } |
| 45 | +oid_t GetTargetIndex(const TargetList &target_list, uint32_t index) { |
| 46 | + oid_t target_size = target_list.size(); |
| 47 | + for (oid_t i = 0; i < target_size; i++) { |
| 48 | + if (target_list[i].first == index) { |
| 49 | + return i; |
| 50 | + } |
49 | 51 | }
|
50 |
| - return false; |
| 52 | + return INVALID_OID; |
51 | 53 | }
|
52 | 54 |
|
53 | 55 | void UpdateTranslator::InitializeState() {
|
@@ -93,13 +95,12 @@ void UpdateTranslator::Consume(ConsumerContext &, RowBatch::Row &row) const {
|
93 | 95 |
|
94 | 96 | // Collect all the column values
|
95 | 97 | std::vector<codegen::Value> values;
|
96 |
| - for (uint32_t i = 0, target_id = 0; i < column_num; i++) { |
| 98 | + for (uint32_t i = 0; i < column_num; i++) { |
97 | 99 | codegen::Value val;
|
98 |
| - if (IsTarget(target_list, i)) { |
99 |
| - // Set the value for the update |
100 |
| - const auto &derived_attribute = target_list[target_id].second; |
| 100 | + uint32_t target_index = GetTargetIndex(target_list,i); |
| 101 | + if (target_index != INVALID_OID) { |
| 102 | + const auto &derived_attribute = target_list[target_index].second; |
101 | 103 | val = row.DeriveValue(codegen, *derived_attribute.expr);
|
102 |
| - target_id++; |
103 | 104 | } else {
|
104 | 105 | val = row.DeriveValue(codegen, ais[i]);
|
105 | 106 | }
|
|
0 commit comments