crash fix in distinct (strict weak ordering)
This commit is contained in:
@@ -1,10 +1,8 @@
|
|||||||
### WIP
|
### WIP
|
||||||
compare in row.cpp shoud take into account m_visible
|
|
||||||
|
|
||||||
### TODO
|
### TODO
|
||||||
- create local_install.sh
|
- create local_install.sh
|
||||||
|
|
||||||
|
|
||||||
- change float type keyword to double and in code functions too
|
- change float type keyword to double and in code functions too
|
||||||
|
|
||||||
- add functions:
|
- add functions:
|
||||||
|
|||||||
3
row.cpp
3
row.cpp
@@ -157,9 +157,6 @@ void Row::setColumnValue(ColDefNode *col_def, ValueNode *col_value) {
|
|||||||
|
|
||||||
int Row::compare(const Row &other) const {
|
int Row::compare(const Row &other) const {
|
||||||
for (size_t ci = 0; ci < m_columns.size(); ci++) {
|
for (size_t ci = 0; ci < m_columns.size(); ci++) {
|
||||||
// CRASHES HERE
|
|
||||||
// auto a = this->operator[](ci).getStringValue();
|
|
||||||
// auto b = other[ci].getStringValue();
|
|
||||||
int cmp = this->operator[](ci).compare(other[ci]);
|
int cmp = this->operator[](ci).compare(other[ci]);
|
||||||
if (cmp != 0) return cmp;
|
if (cmp != 0) return cmp;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,8 +155,7 @@ void USql::setup_order_columns(std::vector<ColOrderNode> &node, Table *table) {
|
|||||||
void USql::execute_distinct(SelectFromTableNode &node, Table *result) {
|
void USql::execute_distinct(SelectFromTableNode &node, Table *result) {
|
||||||
if (!node.distinct) return;
|
if (!node.distinct) return;
|
||||||
|
|
||||||
auto compare_rows = [](const Row &a, const Row &b) { return a.compare(b) >= 0; };
|
std::sort(result->m_rows.begin(), result->m_rows.end(), [](const Row &a, const Row &b) { return a.compare(b) > 0; });
|
||||||
std::sort(result->m_rows.begin(), result->m_rows.end(), compare_rows);
|
|
||||||
|
|
||||||
result->m_rows.erase(std::unique(result->m_rows.begin(), result->m_rows.end()), result->m_rows.end());
|
result->m_rows.erase(std::unique(result->m_rows.begin(), result->m_rows.end()), result->m_rows.end());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user