<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Sep 6, 2014 at 12:59 PM, Huidae Cho <span dir="ltr"><<a href="mailto:grass4u@gmail.com" target="_blank">grass4u@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>Glad to hear that you solved the issue. Even before this revision, <span style="font-size:13px;font-family:arial,sans-serif">strcmp(db_get_default_driver_</span><span style="font-size:13px;font-family:arial,sans-serif">name(), "pg") was there... Anyway, I think initializing a database connection in the location wizard is the right way to fix it.</span></div></div></blockquote><div><br></div><div>I might have looked at wrong revision. Still, if the default db connection is uninitialized, v.in.ogr would crash. I don't know if there is some other case where this could happen, probably not.</div><div><br></div><div>Anna</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="font-size:13px;font-family:arial,sans-serif"><br></span></div><div><span style="font-size:13px;font-family:arial,sans-serif">Thanks.</span></div><div><span style="font-size:13px;font-family:arial,sans-serif">Huidae</span></div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On Sat, Sep 6, 2014 at 9:25 AM, Anna Petrášová <span dir="ltr"><<a href="mailto:kratochanna@gmail.com" target="_blank">kratochanna@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div>On Fri, Sep 5, 2014 at 11:54 PM, Anna Petrášová <span dir="ltr"><<a href="mailto:kratochanna@gmail.com" target="_blank">kratochanna@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 30, 2014 at 12:46 AM, <span dir="ltr"><<a href="mailto:svn_grass@osgeo.org" target="_blank">svn_grass@osgeo.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: hcho<br>
Date: 2014-05-29 21:46:55 -0700 (Thu, 29 May 2014)<br>
New Revision: 60596<br>
<br>
Modified:<br>
grass/trunk/vector/v.in.ogr/main.c<br>
Log:<br>
v.in.ogr: fallback datetime type for pg and dbf drivers<br>
<br>
Modified: grass/trunk/vector/v.in.ogr/main.c<br>
===================================================================<br>
--- grass/trunk/vector/v.in.ogr/main.c 2014-05-30 04:01:53 UTC (rev 60595)<br>
+++ grass/trunk/vector/v.in.ogr/main.c 2014-05-30 04:46:55 UTC (rev 60596)<br>
@@ -103,6 +103,8 @@<br>
int OFTIntegerListlength;<br>
<br>
char *dsn;<br>
+ const char *driver_name;<br>
+ char *datetime_type;<br>
char *output;<br>
char **layer_names; /* names of layers to be imported */<br>
int *layers; /* layer indexes */<br>
@@ -336,9 +338,18 @@<br>
G_fatal_error(_("Required parameter <%s> not set"), param.dsn->key);<br>
}<br>
<br>
+ driver_name = db_get_default_driver_name();<br>
+<br>
+ if (strcmp(driver_name, "pg") == 0)<br>
+ datetime_type = G_store("timestamp with time zone");<br>
+ else if (strcmp(driver_name, "dbf") == 0)<br>
+ datetime_type = G_store("varchar(22)");<br>
+ else<br>
+ datetime_type = G_store("datetime");<br>
+<br>
/* dsn is 'PG:', check default connection settings */<br>
dsn = NULL;<br>
- if (strcmp(db_get_default_driver_name(), "pg") == 0 &&<br>
+ if (strcmp(driver_name, "pg") == 0 &&<br>
G_strcasecmp(param.dsn->answer, "PG:") == 0) {<br>
const char *dbname;<br>
dbConnection conn;<br>
@@ -1010,7 +1021,7 @@<br>
sprintf(buf, ", %s time", Ogr_fieldname);<br>
}<br>
else if (Ogr_ftype == OFTDateTime) {<br>
- sprintf(buf, ", %s datetime", Ogr_fieldname);<br>
+ sprintf(buf, ", %s %s", Ogr_fieldname, datetime_type);<br>
#endif<br>
}<br>
else if (Ogr_ftype == OFTString) {<br>
<br>
_______________________________________________<br>
grass-commit mailing list<br>
<a href="mailto:grass-commit@lists.osgeo.org" target="_blank">grass-commit@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/grass-commit" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-commit</a><br>
</blockquote></div><br></div><div class="gmail_extra"><br></div></div></div><div class="gmail_extra">Hi,</div><div class="gmail_extra"><br></div><div class="gmail_extra">this revision broke running v.in.ogr during creating a new location with Location Wizard based on georeferenced file (e.g. shapefile). User is asked if he wants to also import the data into that location and then it fails because v.in.ogr crashes. The problem is on line </div><div class="gmail_extra"><br></div><div class="gmail_extra">driver_name = db_get_default_driver_name();<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">driver_name seems to be NULL. Running the same v.in.ogr command after starting normal grass session works. Is there and initialization missing? </div></div></blockquote><div><br></div></div></div><div>I added db.connect -c before importing the vector in gis_set.py. That seems to solve it (r61815, and backported in r61816).</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br></div><div class="gmail_extra">Thanks,</div><div class="gmail_extra"><br></div><div class="gmail_extra">Anna</div></div>
</blockquote></div><br></div></div>
<br></div></div>_______________________________________________<br>
grass-dev mailing list<br>
<a href="mailto:grass-dev@lists.osgeo.org" target="_blank">grass-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/grass-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-dev</a><br></blockquote></div><br></div>
</blockquote></div><br></div></div>