[GRASS-dev] [bug #5352] (grass) v.db.select segfault if SQL query is malformed

hbowman wrote (Thu, Nov 30 2006 04:54:41):

v.db.select segfaults if SQL query is malformed:

G63> v.db.select -c fish_sites col=site_id where="CAT = 1"
Ai1

G63> v.db.select -c fish_sites col=site_id where="CAT=1"
Segmentation fault

Hamish,

Why do you think "CAT=1" is malformed and "CAT = 1" is not?

See eg. http://www.w3schools.com/sql/sql_where.asp. Both notations are allowed.

Also GRASS manual mentions both, eg.
http://grass.itc.it/grass63/manuals/html63_user/sql.html:

d.vect map where="individual='juvenile'
v.db.update map=roads col=exprtest value=cat/nulltest+cat where=cat=1
echo "UPDATE roads SET exprtest=NULL WHERE cat>2" | db.execute

This bug is similar to my recent
http://intevation.de/rt/webrt?serial_num=5341, please see the recent notes.

Maciek

-------------------------------------------- Managed by Request Tracker

http://intevation.de/rt/webrt?serial_num=5341

Well, that didn't take long. We now have a nasty 6.2.1 blocker bug.
See the spearfish example below.

HB:

> v.db.select segfaults if SQL query is malformed:
>
> G63> v.db.select -c fish_sites col=site_id where="CAT = 1"
> Ai1
>
> G63> v.db.select -c fish_sites col=site_id where="CAT=1"
> Segmentation fault

MS:

Why do you think "CAT=1" is malformed and "CAT = 1" is not?
See eg. http://www.w3schools.com/sql/sql_where.asp. Both notations are
allowed.

Also GRASS manual mentions both, eg.
http://grass.itc.it/grass63/manuals/html63_user/sql.html:

d.vect map where="individual='juvenile'

yes you are correct. (fyi, I put that example in, we were tracking
the movements of sea lion pups)

re-testing for that sea lion map, it is only v.db.select that is broken.
d.vect, v.extract work without the extra whitespace.

the column= where= options are newer than 6.0.2, so can't test that, but
they do break in 6.1.0.

This bug is similar to my recent
http://intevation.de/rt/webrt?serial_num=5341,

It is the same bug. Merged.

#spearfish

#includes Brad's updates from 2 days ago

G63> v.db.select -c archsites where="CAT = 1"
1|Signature Rock

G63> v.db.select -c archsites where="CAT=1"
DBMI-DBF driver error:
SQL parser error in statement:
SELECT * FROM archsites WHERE CAT=1)
Error in db_open_select_cursor()
ERROR: Cannot open select cursor

G63> v.db.select -c archsites column=str1 where="CAT = 1"
Signature Rock

G63> v.db.select -c archsites column=str1 where="CAT=1"
No Name

G63> v.db.select archsites where="CAT = 1" col=cat
cat
1

G63> v.db.select archsites where="CAT=1" col=cat
cat
11

==> that is very bad, it reports the attribute of the wrong cat !

Hamish

For the thread completeness - Hamish has fixed this in CVS.

Maciek