refactorings
This commit is contained in:
35
usql_dml.cpp
35
usql_dml.cpp
@@ -4,8 +4,9 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace usql {
|
||||
|
||||
namespace usql {
|
||||
|
||||
|
||||
std::pair<bool, std::vector<rowid_t>> USql::probe_index_scan(const Node *where, Table *table) const {
|
||||
bool indexscan_possible = normalize_where(where);
|
||||
@@ -85,28 +86,28 @@ void USql::select_row(SelectFromTableNode &where_node,
|
||||
const std::vector<int> &src_table_col_index,
|
||||
bool is_aggregated) {
|
||||
|
||||
Row *rslt_row = nullptr;
|
||||
Row *rslt_row = nullptr;
|
||||
|
||||
// when aggregate functions in rslt_table only one row exists
|
||||
if (is_aggregated && !rslt_table->empty())
|
||||
rslt_row = &rslt_table->m_rows[0];
|
||||
else
|
||||
rslt_row = &rslt_table->create_empty_row();
|
||||
if (is_aggregated && !rslt_table->empty())
|
||||
rslt_row = &rslt_table->m_rows[0];
|
||||
else
|
||||
rslt_row = &rslt_table->create_empty_row();
|
||||
|
||||
for (auto idx = 0; idx < rslt_table->columns_count(); idx++) {
|
||||
auto src_table_col_idx = src_table_col_index[idx];
|
||||
for (auto idx = 0; idx < rslt_table->columns_count(); idx++) {
|
||||
auto src_table_col_idx = src_table_col_index[idx];
|
||||
|
||||
if (src_table_col_idx == FUNCTION_CALL) {
|
||||
auto evaluated_value = eval_value_node(src_table, *src_row, where_node.cols_names->operator[](idx).value.get(),
|
||||
const_cast<ColDefNode *>(&rslt_tbl_col_defs[idx]), &rslt_row->operator[](idx));
|
||||
ValueNode *col_value = evaluated_value.get();
|
||||
if (src_table_col_idx == FUNCTION_CALL) {
|
||||
auto evaluated_value = eval_value_node(src_table, *src_row, where_node.cols_names->operator[](idx).value.get(),
|
||||
const_cast<ColDefNode *>(&rslt_tbl_col_defs[idx]), &rslt_row->operator[](idx));
|
||||
ValueNode *col_value = evaluated_value.get();
|
||||
|
||||
rslt_row->setColumnValue((ColDefNode *) &rslt_tbl_col_defs[idx], col_value);
|
||||
} else {
|
||||
ColValue &col_value = src_row->operator[](src_table_col_idx);
|
||||
rslt_row->setColumnValue((ColDefNode *) &rslt_tbl_col_defs[idx], col_value);
|
||||
}
|
||||
rslt_row->setColumnValue((ColDefNode *) &rslt_tbl_col_defs[idx], col_value);
|
||||
} else {
|
||||
ColValue &col_value = src_row->operator[](src_table_col_idx);
|
||||
rslt_row->setColumnValue((ColDefNode *) &rslt_tbl_col_defs[idx], col_value);
|
||||
}
|
||||
}
|
||||
|
||||
// for aggregate is validated more than needed
|
||||
rslt_table->commit_row(*rslt_row);
|
||||
|
||||
Reference in New Issue
Block a user