[GRASS5] [bug #4056] (grass) db.test fails on sqlite driver

Radim wrote to the grasslist on 2006.02.17:

---
select c1 from grass_test1 where d1 < 500 / 2 and i1 <> 2 and c1 ~ 'bc'
DBMI-SQLite driver error:
Error in sqlite3_prepare():select c1 from grass_test1 where d1 < 500 / 2 and
i1 <> 2 and c1 ~ 'bc'
near "~": syntax error
EXECUTE: ******** ERROR ********

'~' is not SQL standard, this is not a bug.
---

So what to do with it? Good to know it is not a bug in sqlite driver, but it
remains a bug in db.test. It may scare naive users and prevent from using
sqlite, too bad. Well, it scarred me. Gosh, I'm naive.

Maciek

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

On Fri, Feb 17, 2006 at 06:04:33PM +0100, Maciek Sieczka via RT wrote:

Radim wrote to the grasslist on 2006.02.17:

---
select c1 from grass_test1 where d1 < 500 / 2 and i1 <> 2 and c1 ~ 'bc'
DBMI-SQLite driver error:
Error in sqlite3_prepare():select c1 from grass_test1 where d1 < 500 / 2 and
i1 <> 2 and c1 ~ 'bc'
near "~": syntax error
EXECUTE: ******** ERROR ********

'~' is not SQL standard, this is not a bug.
---

I consider it as bug as SQLite supports '~':

http://www.sqlite.org/lang_expr.html

"Supported unary operators are these:

- + ! ~
"

Question is if it is probably not passed correctly to sqlite?

Markus

Markus Neteler wrote:

> ---
> select c1 from grass_test1 where d1 < 500 / 2 and i1 <> 2 and c1 ~ 'bc'
> DBMI-SQLite driver error:
> Error in sqlite3_prepare():select c1 from grass_test1 where d1 < 500 / 2 and
> i1 <> 2 and c1 ~ 'bc'
> near "~": syntax error
> EXECUTE: ******** ERROR ********
>
> '~' is not SQL standard, this is not a bug.
> ---
>

I consider it as bug as SQLite supports '~':

http://www.sqlite.org/lang_expr.html

"Supported unary operators are these:

- + ! ~

Note the use of the word "unary". In the above select statement, the ~
is being used as a /binary/ operator, which SQLite doesn't support:

  SQLite understands the following binary operators, in order from
  highest to lowest precedence:
  
      ||
      * / %
      + -
      << >> & |
      < <= > >=
      = == != <> IN
      AND
      OR

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

On Fri, Feb 17, 2006 at 06:11:02PM +0000, Glynn Clements wrote:

Markus Neteler wrote:

> > ---
> > select c1 from grass_test1 where d1 < 500 / 2 and i1 <> 2 and c1 ~ 'bc'
> > DBMI-SQLite driver error:
> > Error in sqlite3_prepare():select c1 from grass_test1 where d1 < 500 / 2 and
> > i1 <> 2 and c1 ~ 'bc'
> > near "~": syntax error
> > EXECUTE: ******** ERROR ********
> >
> > '~' is not SQL standard, this is not a bug.
> > ---
> >
>
> I consider it as bug as SQLite supports '~':
>
> http://www.sqlite.org/lang_expr.html
>
> "Supported unary operators are these:
>
> - + ! ~

Note the use of the word "unary". In the above select statement, the ~
is being used as a /binary/ operator, which SQLite doesn't support:

  SQLite understands the following binary operators, in order from
  highest to lowest precedence:
  
      ||
      * / %
      + -
      << >> & |
      < <= > >=
      = == != <> IN
      AND
      OR

Ah, I see - but what does it mean for db.test?
Add a sqlite test to skip it?

Markus

Markus Neteler wrote:

> > > select c1 from grass_test1 where d1 < 500 / 2 and i1 <> 2 and c1 ~ 'bc'
> > > DBMI-SQLite driver error:
> > > Error in sqlite3_prepare():select c1 from grass_test1 where d1 < 500 / 2 and
> > > i1 <> 2 and c1 ~ 'bc'
> > > near "~": syntax error
> > > EXECUTE: ******** ERROR ********
> > >
> > > '~' is not SQL standard, this is not a bug.
> > > ---
> > >
> >
> > I consider it as bug as SQLite supports '~':
> >
> > http://www.sqlite.org/lang_expr.html
> >
> > "Supported unary operators are these:
> >
> > - + ! ~
>
> Note the use of the word "unary". In the above select statement, the ~
> is being used as a /binary/ operator, which SQLite doesn't support:
>
> SQLite understands the following binary operators, in order from
> highest to lowest precedence:
>
> ||
> * / %
> + -
> << >> & |
> < <= > >=
> = == != <> IN
> AND
> OR
>

Ah, I see - but what does it mean for db.test?
Add a sqlite test to skip it?

As it's an extension (rather than standard SQL), the test should be
disabled by default and only run (if at all) for specific back-ends
which are known to support it.

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