Thread: Negative offsets
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
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
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
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. +