[GRASS-SVN] r58302 - grass/trunk/db/drivers/postgres

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Nov 25 02:48:06 PST 2013


Author: martinl
Date: 2013-11-25 02:48:06 -0800 (Mon, 25 Nov 2013)
New Revision: 58302

Modified:
   grass/trunk/db/drivers/postgres/listtab.c
Log:
db-pg: fix db__driver_list_tables() for tables which contain 'pg_' in the name


Modified: grass/trunk/db/drivers/postgres/listtab.c
===================================================================
--- grass/trunk/db/drivers/postgres/listtab.c	2013-11-25 10:30:11 UTC (rev 58301)
+++ grass/trunk/db/drivers/postgres/listtab.c	2013-11-25 10:48:06 UTC (rev 58302)
@@ -21,17 +21,18 @@
 	vschemacol;
     dbString *list;
     PGresult *rest, *resv;
-    char buf[1000];
+    char buf[DB_SQL_MAX];
 
     *tlist = NULL;
     *tcount = 0;
 
 
     /* Get table names */
-    rest =
-	PQexec(pg_conn,
-	       "select * from pg_tables where tablename !~ 'pg_*' order by tablename");
-
+    sprintf(buf, "SELECT * FROM pg_tables WHERE schemaname %s "
+            " ('pg_catalog', 'information_schema') ORDER BY tablename", system ? "IN" : "NOT IN");
+    G_debug(2, "SQL: %s", buf);
+    
+    rest = PQexec(pg_conn, buf);
     if (!rest || PQresultStatus(rest) != PGRES_TUPLES_OK) {
 	db_d_append_error("%s\n%s",
 			  _("Unable to select table names."),
@@ -54,10 +55,11 @@
 
 
     /* Get view names */
-    resv =
-	PQexec(pg_conn,
-	       "SELECT * FROM pg_views WHERE schemaname NOT IN ('pg_catalog','information_schema') AND viewname !~ '^pg_'");
-
+    sprintf(buf, "SELECT * FROM pg_views WHERE schemaname %s "
+            " ('pg_catalog', 'information_schema') ORDER BY viewname", system ? "IN" : "NOT IN");
+    G_debug(2, "SQL: %s", buf);
+    
+    resv = PQexec(pg_conn, buf);
     if (!resv || PQresultStatus(resv) != PGRES_TUPLES_OK) {
 	db_d_append_error("%s\n%s",
 			  _("Unable to select view names."),



More information about the grass-commit mailing list