Browse Source

v.in.ogr: fix default DB connection handling (dsn option is still required)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@59670 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 11 years ago
parent
commit
c2b4db2efa
2 changed files with 13 additions and 10 deletions
  1. 6 6
      vector/v.in.ogr/main.c
  2. 7 4
      vector/v.in.ogr/v.in.ogr.html

+ 6 - 6
vector/v.in.ogr/main.c

@@ -319,10 +319,14 @@ int main(int argc, char *argv[])
 	exit(EXIT_SUCCESS);
     }
 
-    /* dsn not specified, check default connection settings */
+    if (param.dsn->answer == NULL) {
+	G_fatal_error(_("Required parameter <%s> not set"), param.dsn->key);
+    }
+
+    /* dsn is 'PG:', check default connection settings */
     dsn = NULL;
     if (strcmp(db_get_default_driver_name(), "pg") == 0 &&
-        param.dsn->answer == NULL) {
+        G_strcasecmp(param.dsn->answer, "PG:") == 0) {
         const char *dbname;
         dbConnection conn;
         
@@ -358,10 +362,6 @@ int main(int argc, char *argv[])
         dsn = G_store(param.dsn->answer);
     }
     
-    if (dsn == NULL) {
-	G_fatal_error(_("Required parameter <%s> not set"), param.dsn->key);
-    }
-
     min_area = atof(param.min_area->answer);
     snap = atof(param.snap->answer);
     type = Vect_option_to_types(param.type);

+ 7 - 4
vector/v.in.ogr/v.in.ogr.html

@@ -226,8 +226,9 @@ output=polygons type=boundary,centroid
 
 <h3>Default connection settings as datasource (PostgreSQL only)</h3>
 
-Datasource (<b>dsn</b>) can be omitted in the case that default DB
-driver is <a href="grass-pg.html">PostgreSQL</a> (<tt>pg</tt>), see
+If datasource (<b>dsn</b>) is specified as 'PG:' and the default DB
+driver is <a href="grass-pg.html">PostgreSQL</a> (<tt>pg</tt>) than
+the connection string is determined from the default DB settings, see
 examples below.
 
 <p>
@@ -243,7 +244,8 @@ Example (with schema):
 <div class="code"><pre>
 db.connect driver=pg database=test schema=user1
 db.login user=user1 password=pwd1
-v.in.ogr layer=river output=river     # -> table user1.river
+# -> dsn=&quot;PG:dbname=test user=user1 password=pwd1&quot; layer=&quot;user1.river&quot;
+v.in.ogr dsn=PG: layer=river output=river     
 db.select table=user1.river
 </pre></div>
 
@@ -253,7 +255,8 @@ The user can ignore schemas, if desired:
 <div class="code"><pre>
 db.connect driver=pg database=test
 db.login user=user1 password=pwd1
-v.in.ogr layer=river output=river     # -> table public.river
+# -> dsn=&quot;PG:dbname=test user=user1 password=pwd1&quot;
+v.in.ogr dsn=PG: layer=river output=river 
 db.select table=river
 </pre></div>