浏览代码

libvector: support reserved PostgreSQL keywords as column name by quoting when exporting vector map to PostGIS database (contributed by tmsz; fixes https://trac.osgeo.org/grass/ticket/3805)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@74386 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler 6 年之前
父节点
当前提交
e385c1c3a1
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      lib/vector/Vlib/write_pg.c

+ 2 - 2
lib/vector/Vlib/write_pg.c

@@ -693,7 +693,7 @@ int create_table(struct Format_info_pg *pg_info)
             }
 
             /* append column */
-            sprintf(stmt_col, ",%s %s", colname, db_sqltype_name(sqltype));
+            sprintf(stmt_col, ",\"%s\" %s", colname, db_sqltype_name(sqltype));
             strcat(stmt, stmt_col);
             if (sqltype == DB_SQL_TYPE_CHARACTER) {
                 /* length only for string columns */
@@ -2046,7 +2046,7 @@ char *build_insert_stmt(const struct Format_info_pg *pg_info,
 		    }
 
                     /* -> columns */
-                    sprintf(buf_tmp, "%s", colname);
+                    sprintf(buf_tmp, "\"%s\"", colname);
                     strcat(buf, buf_tmp);
                     if (col < ncol - 1)
                         strcat(buf, ",");