Skip to content

Commit

Permalink
Fix order of rows during query; respect file order
Browse files Browse the repository at this point in the history
When buidling the response to a select query, respect the order of rows as given by the file; before the selected rows were given in the reverted order.
Reported by @jockmckechnie on github.
Closes bug #479 .

(cherry picked from commit 54f6c22)
  • Loading branch information
bogdan-iancu committed May 4, 2015
1 parent ae6372f commit 0ad5c10
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions modules/db_text/dbt_res.c
Expand Up @@ -82,6 +82,7 @@ dbt_result_p dbt_result_new(dbt_table_p _dtp, int *_lres, int _sz)
_dres->nrcols = _sz;
_dres->nrrows = 0;
_dres->rows = NULL;
_dres->last = NULL;

return _dres;
clean:
Expand Down Expand Up @@ -291,10 +292,14 @@ int dbt_result_extract_fields(dbt_table_p _dtp, dbt_row_p _drp,
}
}

if(_dres->rows)
(_dres->rows)->prev = _rp;
_rp->next = _dres->rows;
_dres->rows = _rp;
_rp->next = NULL;
if (_dres->last) {
_dres->last->next = _rp;
_rp->prev = _dres->last;
} else {
_dres->rows = _rp;
}
_dres->last = _rp;
_dres->nrrows++;

return 0;
Expand Down
1 change: 1 addition & 0 deletions modules/db_text/dbt_res.h
Expand Up @@ -42,6 +42,7 @@ typedef struct _dbt_result
int nrrows;
dbt_column_p colv;
dbt_row_p rows;
dbt_row_p last;
} dbt_result_t, *dbt_result_p;

//typedef db_res_t dbt_result_t, *dbt_result_p;
Expand Down

0 comments on commit 0ad5c10

Please sign in to comment.