[GRASS-SVN] r40568 - grass/branches/releasebranch_6_4/lib/db/dbmi_client

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jan 20 03:58:40 EST 2010


Author: mmetz
Date: 2010-01-20 03:58:39 -0500 (Wed, 20 Jan 2010)
New Revision: 40568

Modified:
   grass/branches/releasebranch_6_4/lib/db/dbmi_client/copy_tab.c
   grass/branches/releasebranch_6_4/lib/db/dbmi_client/select.c
Log:
improved error handling, fix for trac #461

Modified: grass/branches/releasebranch_6_4/lib/db/dbmi_client/copy_tab.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/db/dbmi_client/copy_tab.c	2010-01-20 08:33:14 UTC (rev 40567)
+++ grass/branches/releasebranch_6_4/lib/db/dbmi_client/copy_tab.c	2010-01-20 08:58:39 UTC (rev 40568)
@@ -249,7 +249,7 @@
 
     if (db_create_table(to_driver, out_table) != DB_OK) {
 	G_warning(_("Unable to create table <%s>"),
-		  out_table);
+		  to_tblname);
 	db_close_database_shutdown_driver(to_driver);
 	if (from_driver != to_driver) {
 	    db_close_database_shutdown_driver(from_driver);

Modified: grass/branches/releasebranch_6_4/lib/db/dbmi_client/select.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/db/dbmi_client/select.c	2010-01-20 08:33:14 UTC (rev 40567)
+++ grass/branches/releasebranch_6_4/lib/db/dbmi_client/select.c	2010-01-20 08:58:39 UTC (rev 40568)
@@ -115,6 +115,11 @@
 
     G_debug(3, "db_select_int()");
 
+    if (col == NULL || strlen(col) == 0) {
+	G_warning(_("Missing column name"));
+	return -1;
+    }
+
     /* allocate */
     alloc = 1000;
     val = (int *)G_malloc(alloc * sizeof(int));
@@ -203,6 +208,16 @@
     dbValue *value;
     dbTable *table;
 
+    if (key == NULL || strlen(key) == 0) {
+	G_warning(_("Missing key column name"));
+	return -1;
+    }
+
+    if (col == NULL || strlen(col) == 0) {
+	G_warning(_("Missing column name"));
+	return -1;
+    }
+
     G_zero(val, sizeof(dbValue));
     sprintf(buf, "SELECT %s FROM %s WHERE %s = %d\n", col, tab, key, id);
     db_init_string(&stmt);
@@ -257,8 +272,18 @@
     dbValue *value;
     dbTable *table;
 
-    G_debug(3, "db_select_db_select_CatValArray ()");
+    G_debug(3, "db_select_CatValArray ()");
 
+    if (key == NULL || strlen(key) == 0) {
+	G_warning(_("Missing key column name"));
+	return -1;
+    }
+
+    if (col == NULL || strlen(col) == 0) {
+	G_warning(_("Missing column name"));
+	return -1;
+    }
+
     db_init_string(&stmt);
 
     sprintf(buf, "SELECT %s, %s FROM %s", key, col, tab);



More information about the grass-commit mailing list