Re: FETCH FIRST clause PERCENT option

From: Erik Rijkers <er(at)xs4all(dot)nl>
To: Surafel Temesgen <surafel3000(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: FETCH FIRST clause PERCENT option
Date: 2018-08-28 16:33:38
Message-ID: 4855d0904a110970e88a662df3c768f4@xs4all.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2018-08-28 14:14, Surafel Temesgen wrote:
> On Tue, Aug 21, 2018 at 3:50 PM Andres Freund <andres(at)anarazel(dot)de>
> wrote:
>
>>
>> Imagine volatile functions being used. That can be problematic because
>> of repeated side-effects, but also will lead to plainly wrong
>> results. Consider what happens with your approach where somebody does
>> something like WHERE value < random().
>>
> Thanks for explaining . The attach patch use tuplestore instead

> [fetch-wth-percent-v2.patch]

I had a quick look at this. Apply, compile, make check are ok.

In straightforward usage seems to work ok.

But I also ran across this crash:

create table if not exists t as
select i from generate_series(1, 100) as f(i);

select * from t
offset 60 rows
fetch next 3 percent rows only
FOR UPDATE
;

TRAP: FailedAssertion("!(slot != ((void *)0))", File: "execTuples.c",
Line: 428)

Erik Rijkers

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Christoph Berg 2018-08-28 16:38:58 Re: logical decoding: ABI break in 10.5 et al
Previous Message Pavel Stehule 2018-08-28 16:06:42 Re: Something's busted in plpgsql composite-variable handling