[GRASS-dev] lib/db/sqlp: how to activate "LIKE" for dbf?
Markus Neteler
neteler at itc.it
Thu Jul 20 03:14:58 EDT 2006
On Thu, Jul 20, 2006 at 06:58:29AM +0100, Glynn Clements wrote:
>
> Markus Neteler wrote:
>
> > Hi,
> >
> > I would like the SQL 'LIKE' to be functional for the
> > dbf driver. While '~' is working, 'LIKE' is rejected.
> > I assume (also tried a bit) that 'LIKE' needs to be
> > mapped to '~' (COMPARISON_OPERATOR, SQL_MTCH) to be passed
> > on to the dbf driver.
> >
> > I didn't manage to implement it right in lib/db/sqlp.
> > Ideas?
>
> I would think that adding:
>
> [Ll][Ii][Kk][Ee] {
> yylval.strval = (char*)strdup("~");
> return COMPARISON_OPERATOR;
> }
>
> to lib/db/sqlp/lex.l should suffice.
Works, thanks.
The DBF driver now understands (sort of) 'LIKE'.
Unfortunately the behaviour isn't yet PostgreSQL compliant:
PostgreSQL says:
http://www.postgresql.org/docs/8.1/interactive/functions-matching.html#FUNCTIONS-LIKE
'abc' LIKE 'abc' true
'abc' LIKE 'a%' true
'abc' LIKE '_b_' true
'abc' LIKE 'c' false
GRASS DBF driver now does:
GRASS 6.1.cvs (pat):~ > v.db.select meteo_stations where="station LIKE 'P0'"
cat|station|east|north
93|P01|1653952|5061546
94|P02|1649511|5063172
95|P03|1640450|5098211
GRASS 6.1.cvs (pat):~ > v.db.select meteo_stations where="station LIKE 'P__'"
cat|station|east|north
GRASS 6.1.cvs (pat):~ > v.db.select meteo_stations where="station LIKE 'P%'"
cat|station|east|north
GRASS 6.1.cvs (pat):~ > v.db.select meteo_stations where="station LIKE 'P'"
cat|station|east|north
93|P01|1653952|5061546
94|P02|1649511|5063172
95|P03|1640450|5098211
GRASS 6.1.cvs (pat):~ >
I don't know where the pattern matching is done for the DBF
driver (db/drivers/dbf/?).
Markus
More information about the grass-dev
mailing list