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

Anna Petrášová kratochanna at gmail.com
Sat Sep 6 10:45:00 PDT 2014


On Sat, Sep 6, 2014 at 12:59 PM, Huidae Cho <grass4u at gmail.com> wrote:

> Hi,
>
> Glad to hear that you solved the issue. Even before this revision,
> strcmp(db_get_default_driver_name(), "pg") was there... Anyway, I think
> initializing  a database connection in the location wizard is the right way
> to fix it.
>

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.

Anna

>
> Thanks.
> Huidae
>
>
> On Sat, Sep 6, 2014 at 9:25 AM, Anna Petrášová <kratochanna at gmail.com>
> wrote:
>
>>
>>
>>
>> On Fri, Sep 5, 2014 at 11:54 PM, Anna Petrášová <kratochanna at gmail.com>
>> wrote:
>>
>>>
>>>
>>>
>>> On Fri, May 30, 2014 at 12:46 AM, <svn_grass at osgeo.org> wrote:
>>>
>>>> Author: hcho
>>>> Date: 2014-05-29 21:46:55 -0700 (Thu, 29 May 2014)
>>>> New Revision: 60596
>>>>
>>>> Modified:
>>>>    grass/trunk/vector/v.in.ogr/main.c
>>>> Log:
>>>> v.in.ogr: fallback datetime type for pg and dbf drivers
>>>>
>>>> Modified: grass/trunk/vector/v.in.ogr/main.c
>>>> ===================================================================
>>>> --- grass/trunk/vector/v.in.ogr/main.c  2014-05-30 04:01:53 UTC (rev
>>>> 60595)
>>>> +++ grass/trunk/vector/v.in.ogr/main.c  2014-05-30 04:46:55 UTC (rev
>>>> 60596)
>>>> @@ -103,6 +103,8 @@
>>>>      int OFTIntegerListlength;
>>>>
>>>>      char *dsn;
>>>> +    const char *driver_name;
>>>> +    char *datetime_type;
>>>>      char *output;
>>>>      char **layer_names;                /* names of layers to be
>>>> imported */
>>>>      int *layers;               /* layer indexes */
>>>> @@ -336,9 +338,18 @@
>>>>         G_fatal_error(_("Required parameter <%s> not set"),
>>>> param.dsn->key);
>>>>      }
>>>>
>>>> +    driver_name = db_get_default_driver_name();
>>>> +
>>>> +    if (strcmp(driver_name, "pg") == 0)
>>>> +       datetime_type = G_store("timestamp with time zone");
>>>> +    else if (strcmp(driver_name, "dbf") == 0)
>>>> +       datetime_type = G_store("varchar(22)");
>>>> +    else
>>>> +       datetime_type = G_store("datetime");
>>>> +
>>>>      /* dsn is 'PG:', check default connection settings */
>>>>      dsn = NULL;
>>>> -    if (strcmp(db_get_default_driver_name(), "pg") == 0 &&
>>>> +    if (strcmp(driver_name, "pg") == 0 &&
>>>>          G_strcasecmp(param.dsn->answer, "PG:") == 0) {
>>>>          const char *dbname;
>>>>          dbConnection conn;
>>>> @@ -1010,7 +1021,7 @@
>>>>                     sprintf(buf, ", %s time", Ogr_fieldname);
>>>>                 }
>>>>                 else if (Ogr_ftype == OFTDateTime) {
>>>> -                   sprintf(buf, ", %s datetime", Ogr_fieldname);
>>>> +                   sprintf(buf, ", %s %s", Ogr_fieldname,
>>>> datetime_type);
>>>>  #endif
>>>>                 }
>>>>                 else if (Ogr_ftype == OFTString) {
>>>>
>>>> _______________________________________________
>>>> grass-commit mailing list
>>>> grass-commit at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/grass-commit
>>>>
>>>
>>>
>>> Hi,
>>>
>>> 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
>>>
>>> driver_name = db_get_default_driver_name();
>>>
>>> driver_name seems to be NULL. Running the same v.in.ogr command after
>>> starting normal grass session works. Is there and initialization missing?
>>>
>>
>> I added db.connect -c before importing the vector in gis_set.py. That
>> seems to solve it (r61815, and backported in r61816).
>>
>>
>>> Thanks,
>>>
>>> Anna
>>>
>>
>>
>> _______________________________________________
>> grass-dev mailing list
>> grass-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/grass-dev
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20140906/1b5e8dbb/attachment-0001.html>


More information about the grass-dev mailing list