basic delete works
This commit is contained in:
parent
ddb9441e23
commit
5e69ce1047
|
|
@ -140,8 +140,8 @@ bool Executor::execute_delete(DeleteFromTableNode& node) {
|
|||
auto it = table->m_rows.begin();
|
||||
for ( ; it != table->m_rows.end(); ) {
|
||||
if (evalWhere(node.where.get(), table, it)) {
|
||||
std::cout << "delete here" << std::endl;
|
||||
++it; // TODO this does not work : it = table->m_rows.erase(it);
|
||||
// TODO this can be really expensive operation
|
||||
it = table->m_rows.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
|
|
|
|||
4
main.cpp
4
main.cpp
|
|
@ -22,10 +22,12 @@ int main(int argc, char *argv[]) {
|
|||
"select i, s from a where i = 1",
|
||||
"select i, s from a where s = 'two'",
|
||||
"select i, s from a where i <= 3 and s = 'one'",
|
||||
"select i, s from a where i > 0",
|
||||
"delete from a where i = 4",
|
||||
"select i, s from a where i > 0",
|
||||
"update a set f = 9.99 where i = 3",
|
||||
// "update a set s = 'three', f = 1.0 + 2.0 where i = 3",
|
||||
"select i, s, f from a where i = 3"
|
||||
// "delete from a where i = 4",
|
||||
// "select i, s from a where i > 0"
|
||||
};
|
||||
|
||||
|
|
|
|||
2
parser.h
2
parser.h
|
|
@ -66,6 +66,8 @@ struct ColDefNode : Node {
|
|||
Node(NodeType::column_def), name(col_name), type(col_type), order(col_order), length(col_len), null(nullable) {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct TrueNode : Node {
|
||||
TrueNode() : Node(NodeType::true_node) {}
|
||||
};
|
||||
|
|
|
|||
5
row.cpp
5
row.cpp
|
|
@ -29,6 +29,11 @@ Row::Row(const Row &other) {
|
|||
}
|
||||
}
|
||||
|
||||
Row& Row::operator=(Row other) {
|
||||
std::swap(m_columns, other.m_columns);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Row::setColumnValue(int col_index, int value) {
|
||||
m_columns[col_index] = std::make_unique<ColIntegerValue>(value);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue