Parameters don't work in FETCH NEXT clause?

From: Shay Rojansky <roji(at)roji(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Parameters don't work in FETCH NEXT clause?
Date: 2016-05-17 15:35:30
Message-ID: CADT4RqBmMaPM03QrZ0w0MqQkxNpRg07FnyQWpCD0j9NSbzAo9Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

A user of mine just raised a strange issue... While it is possible to use a
parameter in a LIMIT clause, PostgreSQL does not seem to allow using one in
a FETCH NEXT clause. In other words, while the following works:

SELECT 1 LIMIT $1;

The following generates a syntax error:

SELECT 1 FETCH NEXT $1 ROWS ONLY;

Since LIMIT and FETCH NEXT are supposed to be equivalent this behavior is
odd.

More generally, is there some documentation on where exactly PostgreSQL
allows parameters and where it doesn't? I occasionally get complaints from
users expecting parameters to work in DDL, or even in table/column names in
SELECT queries... I haven't seen a resource like this.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-05-17 15:35:46 Re: Re: [COMMITTERS] pgsql: Correctly align page's images in generic wal API
Previous Message Magnus Hagander 2016-05-17 15:29:13 Re: Backup doc typo