瀏覽代碼

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 年之前
父節點
當前提交
3f7911afeb
共有 1 個文件被更改,包括 10 次插入1 次删除
  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);