[GRASS-SVN] r54835 - grass/trunk/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Feb 2 03:12:33 PST 2013


Author: martinl
Date: 2013-02-02 03:12:33 -0800 (Sat, 02 Feb 2013)
New Revision: 54835

Modified:
   grass/trunk/lib/vector/Vlib/write_pg.c
Log:
vlib/pg: fix "'" occurrence in text attribute


Modified: grass/trunk/lib/vector/Vlib/write_pg.c
===================================================================
--- grass/trunk/lib/vector/Vlib/write_pg.c	2013-02-02 10:54:16 UTC (rev 54834)
+++ grass/trunk/lib/vector/Vlib/write_pg.c	2013-02-02 11:12:33 UTC (rev 54835)
@@ -1089,9 +1089,13 @@
                             sprintf(buf_tmp, "%.14f",
                                     db_get_value_double(value));
                             break;
-                        case DB_C_TYPE_STRING:
-			    sprintf(buf_tmp, "'%s'", db_get_value_string(value));
+                        case DB_C_TYPE_STRING: {
+                            char *value_tmp;
+                            value_tmp = G_str_replace(db_get_value_string(value), "'", "''");
+                            sprintf(buf_tmp, "'%s'", value_tmp);
+                            G_free(value_tmp);
                             break;
+                        }
                         case DB_C_TYPE_DATETIME:
                             db_convert_column_value_to_string(column,
                                                               &dbstmt);



More information about the grass-commit mailing list