[GRASS-user] problem parsing rows with nulls in column(s) during input (was: error importing postgresql db)

Markus Neteler neteler at osgeo.org
Tue Jun 2 16:34:59 EDT 2009


On Tue, Jun 2, 2009 at 10:09 PM, Seb <spluque at gmail.com> wrote:
> Hi again,
>
> I traced one of the problems with my attempts to import vector and
> associated attribute tables.

Which backend do you use? DBF?

> I found that if some rows contain null
> values for at least one column, then v.in.ascii cannot parse the table
> correctly.

It is not v.in.ascii but the DBMI driver having troubles.

...
>
> Note the empty columns 7 and 11 for all rows.  v.in.ascii produces this
> error:
>
> ---<--------------------cut here---------------start------------------->---
> v.in.ascii in=/tmp/gmt.XQTuDE/test.dat out=test skip=1 x=18 y=19 cat=12 --o --v
> Scanning input for column types...
> Maximum input row length: 159
> Maximum number of columns: 19
> Minimum number of columns: 19
> Column: 1 type: string length: 11
> Column: 2 type: string length: 5
> Column: 3 type: string length: 2
> Column: 4 type: string length: 4
> Column: 5 type: integer
> Column: 6 type: string length: 18
> Column: 7 type: string length: 0
> Column: 8 type: integer
> Column: 9 type: integer
> Column: 10 type: double
> Column: 11 type: string length: 0
> Column: 12 type: integer
> Column: 13 type: integer
> Column: 14 type: string length: 18
> Column: 15 type: string length: 1
> Column: 16 type: double
> Column: 17 type: double
> Column: 18 type: double
> Column: 19 type: double
> Importing points...
>
> Populating table...
> dbmi: Protocol error

I can reproduce it here.

Homework for developers:

db_close_database_shutdown_driver() seems to be oversimplified.
It calls db_close_database(driver) and db_shutdown_driver(driver)
but without testing their return status. Subsequently v.in.ascii cannot
issue a G_fatal_error() in case of "dbmi: Protocol error" as it should.

db_close_database(driver) looks ok:
http://trac.osgeo.org/grass/browser/grass/trunk/lib/db/dbmi_client/c_closedb.c#L26

but less sure about db_shutdown_driver(driver):
http://trac.osgeo.org/grass/browser/grass/trunk/lib/db/dbmi_client/shutdown.c#L39

and not at all about db_close_database_shutdown_driver():
http://trac.osgeo.org/grass/browser/grass/trunk/lib/db/dbmi_client/db.c#L62
which returns brute-force DB_OK.

If db_shutdown_driver(driver) is acceptable, then put if conditions
into db_close_database_shutdown_driver() for DB_FAILED on failure?

Markus


More information about the grass-user mailing list