Browse Source

vlib/pg: check also topology extension when required

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@58238 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 11 years ago
parent
commit
3f7911afeb
1 changed files with 10 additions and 1 deletions
  1. 10 1
      lib/vector/Vlib/open_pg.c

+ 10 - 1
lib/vector/Vlib/open_pg.c

@@ -511,7 +511,16 @@ void connect_db(struct Format_info_pg *pg_info)
         PQfinish(pg_info->conn);
         G_fatal_error(_("Spatial-enabled PostGIS database is required"));
     }
-    
+
+    if (pg_info->toposchema_name) {
+        /* check if topology schema exists */
+        sprintf(stmt, "SELECT COUNT(*) FROM pg_tables WHERE schemaname = 'topology'");
+        if (Vect__execute_get_value_pg(pg_info->conn, stmt) == 0) {
+            PQfinish(pg_info->conn);
+            G_fatal_error(_("PostGIS Topology extension not found in the database"));
+        }
+    }
+
     /* print notice messages only on verbose level */
     PQsetNoticeProcessor(pg_info->conn, notice_processor, NULL);