[GRASS-dev] v.dissolve fails with sqlite driver

Hi,

so far the SQLite driver worked fine for me (after the various fixes) but it
fails
for v.dissolve with a problem which I don't understand:

# Spearfish, create new "sqlite" mapset:

db.connect driver=sqlite
database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite.db'
g.copy vect=quads@neteler,myquads --o
v.db.connect -p myquads

# add table with char column:
v.db.addtable myquads col="name varchar(10)"
# populate with something
v.db.update myquads col=name val="hello"
v.db.select myquads

# dissolved based on varchar column:
v.dissolve myquads out=myquads_diss col=name
...
DBMI-SQLite driver error:
Cannot step:
SQL logic error or missing database

ERROR: Cannot fetch dataa
...

Going into details:

g.gisenv set=DEBUG=3
D3/3: db_start_driver_open_database():
  drvname = sqlite, dbname =
/home/neteler/grassdata/spearfish60/sqlite/sqlite.db
D2/3: opendir
/home/neteler/soft/63grass_cvsexp/dist.i686-pc-linux-gnu/driver/db/

D3/3:
db_driver_open_database()
D3/3: name = '/home/neteler/grassdata/spearfish60/sqlite/sqlite.db'
D2/3: name2 = '/home/neteler/grassdata/spearfish60/sqlite/sqlite.db'
D3/3: SQL: SELECT cat, name FROM myquads ORDER BY name
D3/3: Escaped SQL: SELECT cat, name FROM myquads ORDER BY name
D3/3: describe_table()
D3/3: ncols = 2
D3/3: litetype = 1
D3/3: litetype = 3
D3/3: nkcols = 2
D3/3: litetype = 1
D2/3: col: cat, nkcols 0, litetype : 1, sqltype 3
D3/3: litetype = 3
D2/3: col: name, nkcols 1, litetype : 3, sqltype 13
D3/3: 2 rows selected
D3/3: key type = 15
D3/3: execute: create table myquads_9293 (cat integer, name varchar(255))
D3/3: db__create_index()
D3/3: SQL: create unique index myquads_9293_cat on myquads_9293 ( cat )
D3/3: fetch row = -1
DBMI-SQLite driver error:
Cannot step:
SQL logic error or missing database

ERROR: Cannot fetch data
D3/3: Mapset = sqlite
...

The problem is in db/drivers/sqlite/fetch.c
Any ideas?
thanks,
Makus
--
View this message in context: http://www.nabble.com/v.dissolve-fails-with-sqlite-driver-tf3760326.html#a10628682
Sent from the Grass - Dev mailing list archive at Nabble.com.

Try to run v.dissolve with a 'set -x' to see whether v.extract or
v.reclass is to blame. A hunch could be an unique constraint not
satisfied in the index creation.

Daniel.

On 5/15/07, Markus Neteler <neteler@itc.it> wrote:

Hi,

so far the SQLite driver worked fine for me (after the various fixes) but it
fails
for v.dissolve with a problem which I don't understand:

# Spearfish, create new "sqlite" mapset:

db.connect driver=sqlite
database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite.db'
g.copy vect=quads@neteler,myquads --o
v.db.connect -p myquads

# add table with char column:
v.db.addtable myquads col="name varchar(10)"
# populate with something
v.db.update myquads col=name val="hello"
v.db.select myquads

# dissolved based on varchar column:
v.dissolve myquads out=myquads_diss col=name
...
DBMI-SQLite driver error:
Cannot step:
SQL logic error or missing database

ERROR: Cannot fetch dataa
...

Going into details:

g.gisenv set=DEBUG=3
D3/3: db_start_driver_open_database():
  drvname = sqlite, dbname =
/home/neteler/grassdata/spearfish60/sqlite/sqlite.db
D2/3: opendir
/home/neteler/soft/63grass_cvsexp/dist.i686-pc-linux-gnu/driver/db/

D3/3:
db_driver_open_database()
D3/3: name = '/home/neteler/grassdata/spearfish60/sqlite/sqlite.db'
D2/3: name2 = '/home/neteler/grassdata/spearfish60/sqlite/sqlite.db'
D3/3: SQL: SELECT cat, name FROM myquads ORDER BY name
D3/3: Escaped SQL: SELECT cat, name FROM myquads ORDER BY name
D3/3: describe_table()
D3/3: ncols = 2
D3/3: litetype = 1
D3/3: litetype = 3
D3/3: nkcols = 2
D3/3: litetype = 1
D2/3: col: cat, nkcols 0, litetype : 1, sqltype 3
D3/3: litetype = 3
D2/3: col: name, nkcols 1, litetype : 3, sqltype 13
D3/3: 2 rows selected
D3/3: key type = 15
D3/3: execute: create table myquads_9293 (cat integer, name varchar(255))
D3/3: db__create_index()
D3/3: SQL: create unique index myquads_9293_cat on myquads_9293 ( cat )
D3/3: fetch row = -1
DBMI-SQLite driver error:
Cannot step:
SQL logic error or missing database

ERROR: Cannot fetch data
D3/3: Mapset = sqlite
...

The problem is in db/drivers/sqlite/fetch.c
Any ideas?
thanks,
Makus
--
View this message in context: http://www.nabble.com/v.dissolve-fails-with-sqlite-driver-tf3760326.html#a10628682
Sent from the Grass - Dev mailing list archive at Nabble.com.

_______________________________________________
grass-dev mailing list
grass-dev@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev

--
-- Daniel Calvelo Aros

It is v.reclass which fails:

...
+ v.reclass input=myquads output=myquads_18985 layer=1 column=name
DBMI-SQLite driver error:
Cannot step:
SQL logic error or missing database

FEHLER: Cannot fetch data
+ v.extract -d input=myquads_18985 output=myquads_diss type=area layer=1
...

Concerning constraint
v.db.select myquads
cat|name
1|hello
2|hello

Doing the same with PG driver, it works (also DBF). So it is a problem
in the SQLite driver.

Markus

PS: In below test procedure, it should be
     g.copy vect=quads@PERMANENT,myquads --o
of course

On Tue, May 15, 2007 at 03:56:46PM -0500, Daniel Calvelo wrote:

Try to run v.dissolve with a 'set -x' to see whether v.extract or
v.reclass is to blame. A hunch could be an unique constraint not
satisfied in the index creation.

Daniel.

On 5/15/07, Markus Neteler <neteler@itc.it> wrote:
>
>Hi,
>
>so far the SQLite driver worked fine for me (after the various fixes) but
>it
>fails
>for v.dissolve with a problem which I don't understand:
>
># Spearfish, create new "sqlite" mapset:
>
>db.connect driver=sqlite
>database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite.db'
>g.copy vect=quads@neteler,myquads --o
>v.db.connect -p myquads
>
># add table with char column:
>v.db.addtable myquads col="name varchar(10)"
># populate with something
>v.db.update myquads col=name val="hello"
>v.db.select myquads
>
># dissolved based on varchar column:
>v.dissolve myquads out=myquads_diss col=name
>...
>DBMI-SQLite driver error:
>Cannot step:
>SQL logic error or missing database
>
>ERROR: Cannot fetch dataa
>...
>
>
>Going into details:
>
>g.gisenv set=DEBUG=3
>D3/3: db_start_driver_open_database():
> drvname = sqlite, dbname =
>/home/neteler/grassdata/spearfish60/sqlite/sqlite.db
>D2/3: opendir
>/home/neteler/soft/63grass_cvsexp/dist.i686-pc-linux-gnu/driver/db/
>
>D3/3:
>db_driver_open_database()
>D3/3: name = '/home/neteler/grassdata/spearfish60/sqlite/sqlite.db'
>D2/3: name2 = '/home/neteler/grassdata/spearfish60/sqlite/sqlite.db'
>D3/3: SQL: SELECT cat, name FROM myquads ORDER BY name
>D3/3: Escaped SQL: SELECT cat, name FROM myquads ORDER BY name
>D3/3: describe_table()
>D3/3: ncols = 2
>D3/3: litetype = 1
>D3/3: litetype = 3
>D3/3: nkcols = 2
>D3/3: litetype = 1
>D2/3: col: cat, nkcols 0, litetype : 1, sqltype 3
>D3/3: litetype = 3
>D2/3: col: name, nkcols 1, litetype : 3, sqltype 13
>D3/3: 2 rows selected
>D3/3: key type = 15
>D3/3: execute: create table myquads_9293 (cat integer, name varchar(255))
>D3/3: db__create_index()
>D3/3: SQL: create unique index myquads_9293_cat on myquads_9293 ( cat )
>D3/3: fetch row = -1
>DBMI-SQLite driver error:
>Cannot step:
>SQL logic error or missing database
>
>ERROR: Cannot fetch data
>D3/3: Mapset = sqlite
>...
>
>The problem is in db/drivers/sqlite/fetch.c
>Any ideas?
>thanks,
>Makus
>--
>View this message in context:
>http://www.nabble.com/v.dissolve-fails-with-sqlite-driver-tf3760326.html#a10628682
>Sent from the Grass - Dev mailing list archive at Nabble.com.
>
>_______________________________________________
>grass-dev mailing list
>grass-dev@grass.itc.it
>http://grass.itc.it/mailman/listinfo/grass-dev
>

--
-- Daniel Calvelo Aros

--
Markus Neteler <neteler itc it> http://mpa.itc.it/markus/
FBK-irst - Centro per la Ricerca Scientifica e Tecnologica
MPBA - Predictive Models for Biol. & Environ. Data Analysis
Via Sommarive, 18 - 38050 Povo (Trento), Italy

This bug was kindly fixed by my colleague Antonio Galea...
The sqlite3_reset was wrongly positioned (see
http://www.sqlite.org/capi3ref.html#sqlite3_step )

Cheers
Markus

Markus Neteler wrote:

It is v.reclass which fails:

...
+ v.reclass input=myquads output=myquads_18985 layer=1 column=name
DBMI-SQLite driver error:
Cannot step:
SQL logic error or missing database

FEHLER: Cannot fetch data
+ v.extract -d input=myquads_18985 output=myquads_diss type=area layer=1
...

--
View this message in context: http://www.nabble.com/v.dissolve-fails-with-sqlite-driver-tf3760326.html#a10679257
Sent from the Grass - Dev mailing list archive at Nabble.com.

FYI: Now all sqlite, mysql and postgresl drivers pass this "test".

Markus

Markus Neteler wrote:

This bug was kindly fixed by my colleague Antonio Galea...
The sqlite3_reset was wrongly positioned (see
http://www.sqlite.org/capi3ref.html#sqlite3_step )

Cheers
Markus

--
View this message in context: http://www.nabble.com/v.dissolve-fails-with-sqlite-driver-tf3760326.html#a10696735
Sent from the Grass - Dev mailing list archive at Nabble.com.