[GRASS-SVN] r36574 - grass/branches/develbranch_6/db/drivers/dbf
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Apr 3 03:49:23 EDT 2009
Author: mlennert
Date: 2009-04-03 03:49:23 -0400 (Fri, 03 Apr 2009)
New Revision: 36574
Modified:
grass/branches/develbranch_6/db/drivers/dbf/dbfexe.c
Log:
check for nulls and sort them to the end in ORDER BY clauses
Modified: grass/branches/develbranch_6/db/drivers/dbf/dbfexe.c
===================================================================
--- grass/branches/develbranch_6/db/drivers/dbf/dbfexe.c 2009-04-03 07:17:56 UTC (rev 36573)
+++ grass/branches/develbranch_6/db/drivers/dbf/dbfexe.c 2009-04-03 07:49:23 UTC (rev 36574)
@@ -499,32 +499,47 @@
tbl = &(db.tables[cur_cmp_table]);
- switch (tbl->cols[cur_cmp_ocol].type) {
- case DBF_CHAR:
- c1 = tbl->rows[*row1].values[cur_cmp_ocol].c;
- c2 = tbl->rows[*row2].values[cur_cmp_ocol].c;
- return (strcmp(c1, c2));
- break;
- case DBF_INT:
- i1 = tbl->rows[*row1].values[cur_cmp_ocol].i;
- i2 = tbl->rows[*row2].values[cur_cmp_ocol].i;
- if (i1 < i2)
- return -1;
- if (i1 > i2)
+ if (tbl->rows[*row1].values[cur_cmp_ocol].is_null) {
+ if (tbl->rows[*row2].values[cur_cmp_ocol].is_null) {
+ return 0;
+ }
+ else {
return 1;
- return 0;
- break;
- case DBF_DOUBLE:
- d1 = tbl->rows[*row1].values[cur_cmp_ocol].d;
- d2 = tbl->rows[*row2].values[cur_cmp_ocol].d;
- if (d1 < d2)
+ }
+ }
+ else {
+ if (tbl->rows[*row2].values[cur_cmp_ocol].is_null) {
return -1;
- if (d1 > d2)
- return 1;
- return 0;
- break;
+ }
+ else {
+ switch (tbl->cols[cur_cmp_ocol].type) {
+ case DBF_CHAR:
+ c1 = tbl->rows[*row1].values[cur_cmp_ocol].c;
+ c2 = tbl->rows[*row2].values[cur_cmp_ocol].c;
+ return (strcmp(c1, c2));
+ break;
+ case DBF_INT:
+ i1 = tbl->rows[*row1].values[cur_cmp_ocol].i;
+ i2 = tbl->rows[*row2].values[cur_cmp_ocol].i;
+ if (i1 < i2)
+ return -1;
+ if (i1 > i2)
+ return 1;
+ return 0;
+ break;
+ case DBF_DOUBLE:
+ d1 = tbl->rows[*row1].values[cur_cmp_ocol].d;
+ d2 = tbl->rows[*row2].values[cur_cmp_ocol].d;
+ if (d1 < d2)
+ return -1;
+ if (d1 > d2)
+ return 1;
+ return 0;
+ break;
+ }
+ return 0;
+ }
}
- return 0;
}
static int cmp_row_desc(const void *pa, const void *pb)
More information about the grass-commit
mailing list