Re: keyword LIMIT in SQL-statement, psqlodbc workaround? - Mailing list pgsql-interfaces

From Peter Eisentraut
Subject Re: keyword LIMIT in SQL-statement, psqlodbc workaround?
Date
Msg-id Pine.LNX.4.30.0012230205440.1505-100000@peter.localdomain
Whole thread Raw
In response to keyword LIMIT in SQL-statement, psqlodbc workaround?  ("Johann Zuschlag" <zuschlag2@online.de>)
List pgsql-interfaces
Johann Zuschlag writes:

> I'm using a commercial application. Well, apart from the problem
> that it crashes my psqlodbc.dll (which I'm trying to debug)
> it uses the keyword LIMIT.
>
> Like: CREATE ITEMS (NAME VARCHAR(10), LIMIT NUMERIC...
>
> To my knowledge it worked with PostgreSQL 6.4. Why not with 7.x?

Not sure what was going on in 6.4 but LIMIT is a key word at least since
7.0.  The reason that this is so is the difficulty parsing commands like
this:
SELECT 'xxx' && LIMIT 5;                      ^
When the parser is there it does not know whether && is an infix or
postfix operator, in other words whether LIMIT is an operand (as it could
potentially be if your LIMIT column ever needs to be selected) or a
separate clause.  This could perhaps be fixed with more than one token
lookahead and some sweat, but it hasn't been done.

> I thought it should be possible. Did I misinterpret SQL-92/98?
> MS-SQL and ORACLE are accepting it.

It's not part of SQL, but ORACLE has a similar clause IIRC.

> Since I can't persuade my application to put LIMIT in quotes,
> I need another solution. Any ideas, workarounds how to do it in
> psqlodbc?

You could try rebuilding PostgreSQL with LIMIT renamed to something like
XYZLIMIT (look into src/backend/parser), but that strikes me as a brute
force hack.

-- 
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/



pgsql-interfaces by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: ODBC on Solaris
Next
From: Michael Sims
Date:
Subject: Re: ODBC on Solaris