Re: FETCH FIRST clause PERCENT option - Mailing list pgsql-hackers

From Andrew Gierth
Subject Re: FETCH FIRST clause PERCENT option
Date
Msg-id 871s79qnm1.fsf@news-spur.riddles.org.uk
Whole thread Raw
In response to Re: FETCH FIRST clause PERCENT option  (Surafel Temesgen <surafel3000@gmail.com>)
List pgsql-hackers
>>>>> "Surafel" == Surafel Temesgen <surafel3000@gmail.com> writes:

 Surafel> this is because fetch first values work with integer and it
 Surafel> change fractional number to nearest integer number like select
 Surafel> * from generate_series(1, 1000) fetch first 20.3 rows only; is
 Surafel> not an error rather it return 20 rows.

 31) The declared type of the <simple value specification> simply
     contained in <fetch first percentage> shall be numeric.

Note that unlike <fetch first row count> there is no requirement for the
type to be _exact_ numeric or to have scale 0.

later:

    ii) If <fetch first percentage> is specified, then let FFP be the
        <simple value specification> simply contained in <fetch first
        percentage>, and let LOCT be a <literal> whose value is OCT. Let
        FFRC be the value of

          CEILING ( FFP * LOCT / 100.0E0 )

                NOTE 333 -- The percentage is computed using the number
                of rows before removing the rows specified by <offset
                row count>.

ceil(20.3 * 1000 / 100.0E0) is definitely 203, not 200.

-- 
Andrew.


pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: RHEL 8.0 build
Next
From: Nikolay Shaplov
Date:
Subject: Re: Add extension options to control TAP and isolation tests