[GRASS-SVN] r63889 - grass/trunk/vector/v.univar
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jan 1 03:51:42 PST 2015
Author: martinl
Date: 2015-01-01 03:51:42 -0800 (Thu, 01 Jan 2015)
New Revision: 63889
Modified:
grass/trunk/vector/v.univar/main.c
Log:
v.univar: check if column exists
Modified: grass/trunk/vector/v.univar/main.c
===================================================================
--- grass/trunk/vector/v.univar/main.c 2014-12-31 16:36:47 UTC (rev 63888)
+++ grass/trunk/vector/v.univar/main.c 2015-01-01 11:51:42 UTC (rev 63889)
@@ -349,17 +349,19 @@
Fi->database, Fi->driver);
db_set_error_handler_driver(Driver);
+ /* check if column exists */
+ ctype = db_column_Ctype(Driver, Fi->table, col_opt->answer);
+ if (ctype == -1)
+ G_fatal_error(_("Column <%s> not found in table <%s>"),
+ col_opt->answer, Fi->table);
+ if (ctype != DB_C_TYPE_INT && ctype != DB_C_TYPE_DOUBLE)
+ G_fatal_error(_("Only numeric column type is supported"));
+
/* Note do not check if the column exists in the table because it may be an expression */
db_CatValArray_init(&Cvarr);
- nrec =
- db_select_CatValArray(Driver, Fi->table, Fi->key, col_opt->answer,
- where_opt->answer, &Cvarr);
+ nrec = db_select_CatValArray(Driver, Fi->table, Fi->key, col_opt->answer,
+ where_opt->answer, &Cvarr);
G_debug(2, "db_select_CatValArray() nrec = %d", nrec);
-
- ctype = Cvarr.ctype;
- if (ctype != DB_C_TYPE_INT && ctype != DB_C_TYPE_DOUBLE)
- G_fatal_error(_("Column type not supported"));
-
if (nrec < 0)
G_fatal_error(_("Unable to select data from table"));
More information about the grass-commit
mailing list