[GRASS-dev] string madness

Markus Neteler neteler at itc.it
Sat Mar 17 03:38:13 EDT 2007


Hi,

I am trying to fetch a "date" column in the sqlite driver but
don't quite arrive (just fixed an apparent bug in the column
detection there, but...).
Below is the query, the "datacens" is of special interest.
The points map was imported from PostgreSQL with v.in.ogr
using now the SQLite driver. Checking the table with "sqlite3"
doesn't show any problems, the attribute table looks ok.

But db.select omits to show the "datacens" column contents (ORDER BY
works, not shown here to keep it short):

echo "SELECT * from zecche_BL2001_gis WHERE comune='Zoldo Alto' ORDER BY datacens" | db.select
cat|x_gid|adulti|altitudine|bab_fixed|babesia|bor_fixed|borrelia|cat_|classe|codice|comune|condatm|datacens|datains|datamod|ehr_fixed|ehrlichia|est|fauna|gid|larve|latitude|localita|longitude|ninfe|nord|nsito|nzecche|ric_fixed|rickettsia
D0/0: col:
D0/0: col: f
D0/0: col: n
D0/0: col: n
D0/0: col: Zoldo Alto
D0/0: col: soleggiato
D0/0: col: 2001-04-03       <--- OK!
D0/0: col:
D0/0: col:
D0/0: col: n
D0/0: col: n
D0/0: col: cervo, capriolo
D0/0: col: Le Vare
D0/0: col: 24p
D0/0: col:
D0/0: col: t
2|86|0|1250||f|n|n|114|24|9|Zoldo Alto|soleggiato|0|||n|n|2296670|cervo, capriolo|85|0|46|Le Vare|12|0|5136625|24p|0||t

In the output line the date entry is missing.

Above output was generated with this modification:

db/drivers/sqlite/fetch.c
...
        switch ( litetype ) {
            case SQLITE_TEXT:
                G_debug(0, "col: %s", sqlite3_column_text ( c->statement, col));
                db_set_string ( &(value->s),
                                sqlite3_column_text ( c->statement, col) );
                break;
...

Apparently the db_set_string() fails.
Adding debug output to db_set_string() in lib/db/dbmi_base/string.c
shows that the date string does not "reach" db_set_string() above.
Maybe the '-' chars in 2001-04-03 are evil for db_set_string()?

I have spent meanwhile hours on this and don't know how to fix it (at
least SQLite date column order now works!).
Help appreciated,

Markus




More information about the grass-dev mailing list