some more TODOs resolved
This commit is contained in:
16
usql.cpp
16
usql.cpp
@@ -138,11 +138,12 @@ std::unique_ptr<Table> USql::execute_show(ShowNode &node) {
|
||||
}
|
||||
|
||||
std::unique_ptr<Table> USql::execute_insert_into_table(InsertIntoTableNode &node) {
|
||||
// TODO check column names.size = values.size
|
||||
|
||||
// find table
|
||||
Table *table_def = find_table(node.table_name);
|
||||
|
||||
if (node.cols_names.size() != node.cols_values.size())
|
||||
throw Exception("Incorrect number of values");
|
||||
|
||||
// prepare empty new_row
|
||||
Row& new_row = table_def->create_empty_row();
|
||||
|
||||
@@ -168,8 +169,9 @@ std::unique_ptr<Table> USql::execute_select(SelectFromTableNode &node) {
|
||||
// expand *
|
||||
if (node.cols_names->size()==1 && node.cols_names->operator[](0).name == "*") {
|
||||
node.cols_names->clear();
|
||||
node.cols_names->reserve(table->columns_count());
|
||||
for(auto col : table->m_col_defs) {
|
||||
node.cols_names->push_back(SelectColNode{std::move(std::make_unique<DatabaseValueNode>(col.name)), col.name});
|
||||
node.cols_names->emplace_back(SelectColNode{std::make_unique<DatabaseValueNode>(col.name), col.name});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +181,7 @@ std::unique_ptr<Table> USql::execute_select(SelectFromTableNode &node) {
|
||||
std::vector<int> source_table_col_index{};
|
||||
|
||||
for (int i = 0; i < node.cols_names->size(); i++) {
|
||||
auto [ src_tbl_col_index, rst_tbl_col_def ] = get_column_definition(table, &node.cols_names->operator[](i), i);
|
||||
auto [src_tbl_col_index, rst_tbl_col_def] = get_column_definition(table, &node.cols_names->operator[](i), i);
|
||||
|
||||
source_table_col_index.push_back(src_tbl_col_index);
|
||||
result_tbl_col_defs.push_back(rst_tbl_col_def);
|
||||
@@ -297,7 +299,7 @@ std::unique_ptr<Table> USql::execute_delete(DeleteFromTableNode &node) {
|
||||
Table *table = find_table(node.table_name);
|
||||
|
||||
// execute access plan
|
||||
int affected_rows = table->rows_count();
|
||||
auto affected_rows = table->rows_count();
|
||||
|
||||
table->m_rows.erase(
|
||||
std::remove_if(table->m_rows.begin(), table->m_rows.end(),
|
||||
@@ -565,13 +567,13 @@ std::unique_ptr<ValueNode> USql::eval_arithmetic_operator(ColumnType outType, Ar
|
||||
throw Exception("implement me!!");
|
||||
}
|
||||
}
|
||||
// TODO date node should support addition and substraction
|
||||
// TODO date node should support addition and subtraction
|
||||
|
||||
throw Exception("implement me!!");
|
||||
}
|
||||
|
||||
|
||||
std::unique_ptr<Table> USql::create_stmt_result_table(long code, const std::string &text, long affected_rows) {
|
||||
std::unique_ptr<Table> USql::create_stmt_result_table(long code, const std::string &text, size_t affected_rows) {
|
||||
std::vector<ColDefNode> result_tbl_col_defs{};
|
||||
result_tbl_col_defs.emplace_back("code", ColumnType::integer_type, 0, 1, false);
|
||||
result_tbl_col_defs.emplace_back("desc", ColumnType::varchar_type, 1, 48, false);
|
||||
|
||||
Reference in New Issue
Block a user