Re: FETCH FIRST

Lists: pgsql-hackers
From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: FETCH FIRST
Date: 2008-03-25 14:45:03
Message-ID: 1206456303.4285.926.camel@ebony.site
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

SQL200n specifies a new command similar to our LIMIT

FETCH { FIRST | NEXT } n { ROW | ROWS } ONLY

and also that the OFFSET command can have an optional suffix

{ ROW | ROWS }

Seems like a % project for the TODO list

--
Simon Riggs
2ndQuadrant http://www.2ndQuadrant.com

PostgreSQL UK 2008 Conference: http://www.postgresql.org.uk


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: FETCH FIRST
Date: 2008-03-25 14:45:51
Message-ID: 200803251445.m2PEjps13608@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Simon Riggs wrote:
> SQL200n specifies a new command similar to our LIMIT
>
> FETCH { FIRST | NEXT } n { ROW | ROWS } ONLY
>
> and also that the OFFSET command can have an optional suffix
>
> { ROW | ROWS }
>
> Seems like a % project for the TODO list

Where does this FETCH appear in a SELECT?

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://postgres.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: FETCH FIRST
Date: 2008-03-25 15:11:03
Message-ID: 1206457863.4285.937.camel@ebony.site
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, 2008-03-25 at 10:45 -0400, Bruce Momjian wrote:
> Simon Riggs wrote:
> > SQL200n specifies a new command similar to our LIMIT
> >
> > FETCH { FIRST | NEXT } n { ROW | ROWS } ONLY
> >
> > and also that the OFFSET command can have an optional suffix
> >
> > { ROW | ROWS }
> >
> > Seems like a % project for the TODO list
>
> Where does this FETCH appear in a SELECT?

It's supposed to go *after* the OFFSET clause in a query, but making it
a simple synonym for LIMIT seems most sensible.

It's also allowed as part of the WITH clause (that we don't yet have).

--
Simon Riggs
2ndQuadrant http://www.2ndQuadrant.com

PostgreSQL UK 2008 Conference: http://www.postgresql.org.uk


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: FETCH FIRST
Date: 2008-03-25 15:47:04
Message-ID: 21513.1206460024@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Simon Riggs <simon(at)2ndquadrant(dot)com> writes:
> On Tue, 2008-03-25 at 10:45 -0400, Bruce Momjian wrote:
>> Where does this FETCH appear in a SELECT?

> It's supposed to go *after* the OFFSET clause in a query, but making it
> a simple synonym for LIMIT seems most sensible.

Huh? OFFSET isn't in standard SQL either. Are you sure you're not
confusing FETCH-from-a-cursor with SELECT?

regards, tom lane


From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: FETCH FIRST
Date: 2008-03-25 15:57:59
Message-ID: 1206460679.4285.948.camel@ebony.site
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, 2008-03-25 at 11:47 -0400, Tom Lane wrote:
> Simon Riggs <simon(at)2ndquadrant(dot)com> writes:
> > On Tue, 2008-03-25 at 10:45 -0400, Bruce Momjian wrote:
> >> Where does this FETCH appear in a SELECT?
>
> > It's supposed to go *after* the OFFSET clause in a query, but making it
> > a simple synonym for LIMIT seems most sensible.
>
> Huh? OFFSET isn't in standard SQL either.

Tis now.

> Are you sure you're not
> confusing FETCH-from-a-cursor with SELECT?

Quite sure.

--
Simon Riggs
2ndQuadrant http://www.2ndQuadrant.com

PostgreSQL UK 2008 Conference: http://www.postgresql.org.uk