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

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Mar 30 08:00:07 EDT 2012


Author: martinl
Date: 2012-03-30 05:00:07 -0700 (Fri, 30 Mar 2012)
New Revision: 51195

Modified:
   grass/trunk/lib/vector/Vlib/field.c
Log:
vlib(pg): report full table name (`schema.table`) for tables from non-public schema


Modified: grass/trunk/lib/vector/Vlib/field.c
===================================================================
--- grass/trunk/lib/vector/Vlib/field.c	2012-03-30 11:56:21 UTC (rev 51194)
+++ grass/trunk/lib/vector/Vlib/field.c	2012-03-30 12:00:07 UTC (rev 51195)
@@ -411,7 +411,7 @@
 	return NULL;
     }
 
-    fi = (struct field_info *)malloc(sizeof(struct field_info));
+    fi = (struct field_info *)G_malloc(sizeof(struct field_info));
     fi->number = Map->dblnk->field[link].number;
 
     if (Map->dblnk->field[link].name != NULL)
@@ -810,6 +810,7 @@
 static int read_dblinks_pg(struct Map_info *Map)
 {
 #ifdef HAVE_POSTGRES
+    char *name;
     struct dblinks *dbl;
     struct Format_info_pg *pg_info;
     
@@ -822,9 +823,19 @@
 	return -1;
     }
     G_debug(3, "Using FID column <%s>", pg_info->fid_column);
-    Vect_add_dblink(dbl, 1, pg_info->table_name,
-		    pg_info->table_name, pg_info->fid_column,
+
+    name = NULL;
+    if (G_strcasecmp(pg_info->schema_name, "public") != 0)
+	G_asprintf(&name, "%s.%s", pg_info->schema_name,
+		   pg_info->table_name);
+    else
+	name = pg_info->table_name;
+    
+    Vect_add_dblink(dbl, 1, name, name,
+		    pg_info->fid_column,
 		    pg_info->db_name, "pg");
+    if (name != pg_info->table_name)
+	G_free(name);
     return 1;
 #else
     G_warning(_("GRASS not compiled with PostgreSQL support"));



More information about the grass-commit mailing list