Negative offsets

Started by CSNover 20 years ago4 messagesgeneral
Jump to latest
#1CSN
cool_screen_name90001@yahoo.com

I was playing around with negative offsets:

select * from table1 order by col1 offset -5 limit 25;
select * from table1 order by col1 offset -25 limit
25;
select * from table1 order by col1 offset -250 limit
25;

They all return the same resultset (offset 0). Is
there even any point in allowing negative offsets -
such as maybe someday they'll offset backwards?

thanks
csn

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

#2Bruce Momjian
bruce@momjian.us
In reply to: CSN (#1)
Re: Negative offsets

CSN wrote:

I was playing around with negative offsets:

select * from table1 order by col1 offset -5 limit 25;
select * from table1 order by col1 offset -25 limit
25;
select * from table1 order by col1 offset -250 limit
25;

They all return the same resultset (offset 0). Is
there even any point in allowing negative offsets -
such as maybe someday they'll offset backwards?

Actually we allow negative offsets and limits. Seems we should disallow
them. Yes, it would be interesting if they did offsets relative to the
end of the result set.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#3Jim Nasby
Jim.Nasby@BlueTreble.com
In reply to: Bruce Momjian (#2)
Re: Negative offsets

On Fri, Dec 16, 2005 at 07:14:42PM -0500, Bruce Momjian wrote:

Actually we allow negative offsets and limits. Seems we should disallow
them. Yes, it would be interesting if they did offsets relative to the
end of the result set.

Either interesting or a great way to introduce bugs... AFAIK you can
always get the same behavior just by reversing the sort order, so I'd
lean towards not allowing negative offsets.
--
Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461

#4Bruce Momjian
bruce@momjian.us
In reply to: Bruce Momjian (#2)
Re: Negative offsets

Bruce Momjian wrote:

CSN wrote:

I was playing around with negative offsets:

select * from table1 order by col1 offset -5 limit 25;
select * from table1 order by col1 offset -25 limit
25;
select * from table1 order by col1 offset -250 limit
25;

They all return the same resultset (offset 0). Is
there even any point in allowing negative offsets -
such as maybe someday they'll offset backwards?

Actually we allow negative offsets and limits. Seems we should disallow
them. Yes, it would be interesting if they did offsets relative to the
end of the result set.

Seems most people just want to leave our current behavior unchanged.

--
Bruce Momjian http://candle.pha.pa.us
SRA OSS, Inc. http://www.sraoss.com

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