Re: BUG #18467: postgres_fdw (deparser) ignores LimitOption - Mailing list pgsql-bugs

From Japin Li
Subject Re: BUG #18467: postgres_fdw (deparser) ignores LimitOption
Date
Msg-id ME3P282MB3166558F8BC9798D4872F915B6ED2@ME3P282MB3166.AUSP282.PROD.OUTLOOK.COM
Whole thread Raw
In response to Re: BUG #18467: postgres_fdw (deparser) ignores LimitOption  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Responses Re: BUG #18467: postgres_fdw (deparser) ignores LimitOption
List pgsql-bugs
On Thu, 16 May 2024 at 23:27, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
> On 2024-May-16, Japin Li wrote:
>
>> I find that the FETCH FIRST ... ROWS WITH TIES does not support type casting.
>> For example:
>>
>> postgres=# SELECT * FROM pg_class ORDER BY relname FETCH FIRST 2::bigint ROWS WITH TIES;
>> ERROR:  syntax error at or near "::"
>> LINE 1: ...ECT * FROM pg_class ORDER BY relname FETCH FIRST 2::bigint R...
>>                                                              ^
>
> Why do you need this?  The standard says
>
> <fetch first clause> ::= FETCH { FIRST | NEXT } [ <fetch first quantity> ] { ROW | ROWS } { ONLY | WITH TIES }
> <fetch first quantity> ::= <fetch first row count> | <fetch first percentage>
> <offset row count> ::= <simple value specification>
> <fetch first row count> ::= <simple value specification>
>
> which doesn't seem to leave room for a cast.
>
> I didn't try super extensively, but this works:
>   select 1 from pg_class fetch first 281474976710656 rows only;
> so the count is already not restricted to be an int32 value.

After some dig in, I find transformLimitClause() has the following comments:

 * Note: as of Postgres 8.2, LIMIT expressions are expected to yield int8,
 * rather than int4 as before.

So the deparseConst() append '::bigint' typecast, same as get_rule_expr().

--
Regards,
Japin Li



pgsql-bugs by date:

Previous
From: Japin Li
Date:
Subject: Re: BUG #18467: postgres_fdw (deparser) ignores LimitOption
Next
From: Tom Lane
Date:
Subject: Re: differences between <> and != when using signed values on the right hand side