[GRASS-SVN] r59670 - grass/trunk/vector/v.in.ogr

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Apr 10 09:24:58 PDT 2014


Author: martinl
Date: 2014-04-10 09:24:58 -0700 (Thu, 10 Apr 2014)
New Revision: 59670

Modified:
   grass/trunk/vector/v.in.ogr/main.c
   grass/trunk/vector/v.in.ogr/v.in.ogr.html
Log:
v.in.ogr: fix default DB connection handling (dsn option is still required)


Modified: grass/trunk/vector/v.in.ogr/main.c
===================================================================
--- grass/trunk/vector/v.in.ogr/main.c	2014-04-10 13:19:43 UTC (rev 59669)
+++ grass/trunk/vector/v.in.ogr/main.c	2014-04-10 16:24:58 UTC (rev 59670)
@@ -319,10 +319,14 @@
 	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 @@
         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);

Modified: grass/trunk/vector/v.in.ogr/v.in.ogr.html
===================================================================
--- grass/trunk/vector/v.in.ogr/v.in.ogr.html	2014-04-10 13:19:43 UTC (rev 59669)
+++ grass/trunk/vector/v.in.ogr/v.in.ogr.html	2014-04-10 16:24:58 UTC (rev 59670)
@@ -226,8 +226,9 @@
 
 <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 @@
 <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="PG:dbname=test user=user1 password=pwd1" layer="user1.river"
+v.in.ogr dsn=PG: layer=river output=river     
 db.select table=user1.river
 </pre></div>
 
@@ -253,7 +255,8 @@
 <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="PG:dbname=test user=user1 password=pwd1"
+v.in.ogr dsn=PG: layer=river output=river 
 db.select table=river
 </pre></div>
 



More information about the grass-commit mailing list