[GRASS-SVN] r72864 - grass/trunk/vector/v.to.db
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jun 21 09:01:17 PDT 2018
Author: mmetz
Date: 2018-06-21 09:01:17 -0700 (Thu, 21 Jun 2018)
New Revision: 72864
Modified:
grass/trunk/vector/v.to.db/update.c
Log:
v.to.db: double-quote strings to protect single quotes, as in v.in.ogr
Modified: grass/trunk/vector/v.to.db/update.c
===================================================================
--- grass/trunk/vector/v.to.db/update.c 2018-06-21 14:39:25 UTC (rev 72863)
+++ grass/trunk/vector/v.to.db/update.c 2018-06-21 16:01:17 UTC (rev 72864)
@@ -11,7 +11,7 @@
int i, *catexst, *cex, upd, fcat;
char buf1[2000], buf2[2000], left[20], right[20];
struct field_info *qFi, *Fi;
- dbString stmt;
+ dbString stmt, strval;
dbDriver *driver;
vstat.dupl = 0;
@@ -21,6 +21,7 @@
vstat.error = 0;
db_init_string(&stmt);
+ db_init_string(&strval);
/* layer to find table to read from */
qFi = Vect_get_field(Map, options.qfield);
@@ -196,8 +197,10 @@
Fi->key, Values[i].cat);
break;
case (DB_C_TYPE_STRING):
+ db_set_string(&strval, Values[i].str1);
+ db_double_quote_string(&strval);
sprintf(buf2, "%s '%s' where %s = %d", buf1,
- Values[i].str1, Fi->key, Values[i].cat);
+ db_get_string(&strval), Fi->key, Values[i].cat);
break;
case (DB_C_TYPE_DATETIME):
sprintf(buf2, "%s '%s' where %s = %d", buf1,
@@ -248,6 +251,8 @@
vstat.update++;
}
else {
+ G_warning(_("Cannot update table: %s"),
+ db_get_string(&stmt));
vstat.error++;
}
}
More information about the grass-commit
mailing list