code changes in load
This commit is contained in:
22
usql.cpp
22
usql.cpp
@@ -87,12 +87,14 @@ std::unique_ptr<Table> USql::execute_load(LoadIntoTableNode &node) {
|
||||
Table *table_def = find_table(node.table_name);
|
||||
|
||||
// read data
|
||||
std::ifstream ifs(node.filename);
|
||||
std::string content((std::istreambuf_iterator<char>(ifs)),
|
||||
(std::istreambuf_iterator<char>()));
|
||||
|
||||
// std::ifstream ifs(node.filename);
|
||||
// std::string content((std::istreambuf_iterator<char>(ifs)),
|
||||
// (std::istreambuf_iterator<char>()));
|
||||
// load rows
|
||||
auto rows_cnt = table_def->load_csv_string(content);
|
||||
// auto rows_cnt = table_def->load_csv_string(content);
|
||||
|
||||
|
||||
auto rows_cnt = table_def->load_csv_file(node.filename);
|
||||
|
||||
return create_stmt_result_table(0, "load succeeded", rows_cnt);
|
||||
}
|
||||
@@ -483,12 +485,14 @@ std::unique_ptr<ValueNode> USql::eval_function_value_node(Table *table, Row &row
|
||||
|
||||
|
||||
bool USql::eval_logical_operator(LogicalOperatorNode &node, Table *pTable, Row &row) {
|
||||
bool left = eval_relational_operator(static_cast<const RelationalOperatorNode &>(*node.left), pTable, row);
|
||||
//bool left = eval_relational_operator(static_cast<const RelationalOperatorNode &>(*node.left), pTable, row);
|
||||
bool left = eval_where(&(*node.left), pTable, row);
|
||||
|
||||
if ((node.op == LogicalOperatorType::and_operator && !left) || (node.op == LogicalOperatorType::or_operator && left))
|
||||
return left;
|
||||
|
||||
bool right = eval_relational_operator(static_cast<const RelationalOperatorNode &>(*node.right), pTable, row);
|
||||
//bool right = eval_relational_operator(static_cast<const RelationalOperatorNode &>(*node.right), pTable, row);
|
||||
bool right = eval_where(&(*node.right), pTable, row);
|
||||
return right;
|
||||
}
|
||||
|
||||
@@ -559,7 +563,7 @@ std::unique_ptr<Table> USql::create_stmt_result_table(long code, const std::stri
|
||||
|
||||
Row& new_row = table_def->create_empty_row();
|
||||
new_row.setIntColumnValue(0, code);
|
||||
new_row.setStringColumnValue(1, text);
|
||||
new_row.setStringColumnValue(1, text.size() <= 48 ? text : text.substr(0,48));
|
||||
new_row.setIntColumnValue(2, affected_rows);
|
||||
table_def->commit_row(new_row);
|
||||
|
||||
@@ -587,4 +591,4 @@ void USql::check_table_not_exists(const std::string &name) {
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user