[GRASS-SVN] r64099 - grass/branches/releasebranch_7_0/vector/v.external

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jan 12 07:52:08 PST 2015


Author: martinl
Date: 2015-01-12 07:52:08 -0800 (Mon, 12 Jan 2015)
New Revision: 64099

Modified:
   grass/branches/releasebranch_7_0/vector/v.external/list.c
Log:
v.external: fix -t flag output for PG format (print also geometry column)
            (merge r64098 from trunk)


Modified: grass/branches/releasebranch_7_0/vector/v.external/list.c
===================================================================
--- grass/branches/releasebranch_7_0/vector/v.external/list.c	2015-01-12 15:46:21 UTC (rev 64098)
+++ grass/branches/releasebranch_7_0/vector/v.external/list.c	2015-01-12 15:52:08 UTC (rev 64099)
@@ -142,7 +142,7 @@
 int list_layers_pg(FILE *fd, const char *conninfo, const char *table, int print_types)
 {
     int   row, ntables, ret, print_schema;
-    char *value_schema, *value_table;
+    char *value_schema, *value_table, *value_type, *value_column;
     char *schema_name, *table_name;
     
     PGconn   *conn;
@@ -159,7 +159,7 @@
 		      PQerrorMessage(conn));
     
     db_init_string(&sql);
-    db_set_string(&sql, "SELECT f_table_schema, f_table_name, type "
+    db_set_string(&sql, "SELECT f_table_schema, f_table_name, f_geometry_column, type "
 		  "FROM geometry_columns ORDER BY "
 		  "f_table_schema, f_table_name");
     G_debug(2, "SQL: %s", db_get_string(&sql));
@@ -197,15 +197,16 @@
     for (row = 0; row < ntables; row++) {	
 	value_schema = PQgetvalue(res, row, 0);
 	value_table = PQgetvalue(res, row, 1);
+        value_column = PQgetvalue(res, row, 2);
+        value_type = PQgetvalue(res, row, 3);
+        
 	if (fd) {
 	    if (print_types) {
 		if (print_schema && G_strcasecmp(value_schema, "public") != 0)
-		    fprintf(fd, "%s.%s,%s,0\n",
-			    value_schema, value_table,
-			    feature_type(PQgetvalue(res, row, 2)));
-		else 
-		    fprintf(fd, "%s,%s,0\n", value_table,
-			    feature_type(PQgetvalue(res, row, 2)));
+                    fprintf(fd, "%s.", value_schema);
+                
+                fprintf(fd, "%s,%s,0,%s\n", value_table,
+                        feature_type(value_type), value_column);
 	    }
 	    else {
 		if (print_schema && G_strcasecmp(value_schema, "public") != 0)



More information about the grass-commit mailing list