<div dir="ltr"><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">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 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 class="gmail_extra"><br></div><div class="gmail_extra">Thanks,</div><div class="gmail_extra"><br></div><div class="gmail_extra">Anna</div></div>