[GRASS-user] strange Postgres/DBF table (layer 2) issue

Glynn Clements glynn at gclements.plus.com
Fri Oct 17 13:16:51 EDT 2008


peter.loewe at gmx.de wrote:

> Trying it from the other side by creating a new table by v.db.addtable
> also causes trouble:
> 
>  v.db.addtable map=landkreise_alpha table=smith layer=2 'columns=cat integer,id_int integer,id_varchar varchar(10),name varchar(30)'
> 
>  produces indeed a new table, but surprisingly NOT IN POSTGRES:
> 
> GRASS 6.3.0 (foo):~ > v.db.addtable map=landkreise_alpha table=smith layer=2 'columns=cat integer,id_int integer,id_varchar varchar(10),name varchar(30)'
> Using user specified table name: smith
> Creating table with columns (cat integer, id_int integer,id_varchar
> varchar(10),name varchar(30))
> The table <smith> is now part of vector map <landkreise_alpha> and may be
> deleted or overwritten by GRASS modules
> Select privileges were granted on the table
> Updating database...
>  100%
> 1 categories read from map
> 0 records selected from table
> 0 categories read from map exist in selection from table
> 0 categories read from map don't exist in selection from table
> 0 records updated/inserted
> 0 update/insert errors
> Current attribute table links:
> Vector map <landkreise_alpha> is connected by:
> layer <1> table <landkreise_alpha> in database </home/pel/sandbox/locations/alpha/dbf/> through driver <dbf> with key <cat>
> layer <2> table <smith> in database </home/pel/sandbox/locations/alpha/dbf/> through driver <dbf> with key <cat>
> 
> ^^^--- why, oh why is the new table set up through the dbf-Driver
> when the whole mapset has been switched to the PG-driver ?

If a table is connected to layer 1, v.db.addtable uses the same driver
and database parameters for the new table. It only uses the defaults
if no table is connected to layer 1.

I don't know whether this is because there is some problem with using
different database for different layers of the same map, or whether it
was a "feature" which seemed like a good idea at the time.

I suggest submitting an enhancement request (on the tracker) for a
switch to allow this behaviour to be overriden.

In the meantime, v.db.addtable is just a shell script; you can modify
it to skip the autodetection; see the "check if anything is connected"
comment for the relevant part of the script.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list