In the SQL standard, FETCH is accepted (not LIMIT). Postgres supports both and they're both equivalent.
GlareDB parses/understands FETCH, but doesn't actually apply the limits.
So for example, if I make a syntax error:
select distinct name from pg_db.public.users order by name fetch;
I get:
sql parser error: Expected one of FIRST or NEXT, found: ;
Expected
select distinct name
from pg_db.public.users
order by name asc
fetch first row only;
and
select distinct name
from pg_db.public.users
order by name asc
limit 1;
both return the same result:
name
------
Ashley McClelland
Actual
select distinct name
from pg_db.public.users
order by name asc
limit 1;
select distinct name
from pg_db.public.users
order by name asc
fetch first row only;
name
------
Ashley McClelland
name
------
Ashley McClelland
Clint Kadera
Garrett Delfosse
Grey Barkans
Sean Smith
Vaibhav Rabber
Impact
Because that FETCH is understood by postgres, and is more sql standard, it's likely a customer or user will have a prebaked query/script somewhere that uses it.
What's worse is that we don't throw any errors (but do throw errors if the syntax isn't parsed correctly), but just simply don't apply the limit.
Context
In the SQL standard,
FETCH
is accepted (notLIMIT
). Postgres supports both and they're both equivalent.GlareDB parses/understands
FETCH
, but doesn't actually apply the limits.So for example, if I make a syntax error:
I get:
Expected
and
both return the same result:
Actual
Impact
Because that
FETCH
is understood by postgres, and is more sql standard, it's likely a customer or user will have a prebaked query/script somewhere that uses it.What's worse is that we don't throw any errors (but do throw errors if the syntax isn't parsed correctly), but just simply don't apply the limit.