Re: [HACKERS] Support for negative index values in array fetching

2011-01-09 Thread Hannu Valtonen
On 1/5/11 6:19 PM, Florian Pflug wrote: Sorry, but It isn't too intuitive. Minimally for me. Why you don't thinking about simple functions with only positive arguments. There are only four combinations. I don't think we must have only one super function. we need functionality for: a) get first

Re: [HACKERS] Support for negative index values in array fetching

2011-01-05 Thread Pavel Stehule
2011/1/5 Florian Pflug : > On Jan5, 2011, at 15:17 , Pavel Stehule wrote: >> 2011/1/5 Florian Pflug : >>> How so? You'd still be able to get the last element by simply writing >>> >>>  array_relative(some_array, array[-1]). >>> >>> Or, if we made the function variadic, by writing >>> >>>  array_rel

Re: [HACKERS] Support for negative index values in array fetching

2011-01-05 Thread Florian Pflug
On Jan5, 2011, at 15:17 , Pavel Stehule wrote: > 2011/1/5 Florian Pflug : >> How so? You'd still be able to get the last element by simply writing >> >> array_relative(some_array, array[-1]). >> >> Or, if we made the function variadic, by writing >> >> array_relative(some_array, -1). > > Sorr

Re: [HACKERS] Support for negative index values in array fetching

2011-01-05 Thread Pavel Stehule
2011/1/5 Florian Pflug : > On Jan5, 2011, at 13:08 , Pavel Stehule wrote: >> 2011/1/5 Florian Pflug : >>> On Jan5, 2011, at 10:25 , Peter Eisentraut wrote: On sön, 2011-01-02 at 12:47 +0100, Florian Pflug wrote: > The only way around that would be to introduce magic constants "lower", >>>

Re: [HACKERS] Support for negative index values in array fetching

2011-01-05 Thread Florian Pflug
On Jan5, 2011, at 13:08 , Pavel Stehule wrote: > 2011/1/5 Florian Pflug : >> On Jan5, 2011, at 10:25 , Peter Eisentraut wrote: >>> On sön, 2011-01-02 at 12:47 +0100, Florian Pflug wrote: The only way around that would be to introduce magic constants "lower", "upper" that can be used

Re: [HACKERS] Support for negative index values in array fetching

2011-01-05 Thread Pavel Stehule
2011/1/5 Florian Pflug : > On Jan5, 2011, at 10:25 , Peter Eisentraut wrote: >> On sön, 2011-01-02 at 12:47 +0100, Florian Pflug wrote: >>> The only way around that would be to introduce magic constants "lower", >>> "upper" that >>> can be used within index expressions and evaluate to the indexed

Re: [HACKERS] Support for negative index values in array fetching

2011-01-05 Thread Florian Pflug
On Jan5, 2011, at 10:25 , Peter Eisentraut wrote: > On sön, 2011-01-02 at 12:47 +0100, Florian Pflug wrote: >> The only way around that would be to introduce magic constants "lower", >> "upper" that >> can be used within index expressions and evaluate to the indexed dimension's >> lower >> and up

Re: [HACKERS] Support for negative index values in array fetching

2011-01-05 Thread Pavel Stehule
Hello 2011/1/5 Peter Eisentraut : > On sön, 2011-01-02 at 12:47 +0100, Florian Pflug wrote: >> > Here's a patch to add support for negative index values in fetching >> > elements from an array. >> negative arguments for array can be really strange >> That won't work. In SQL, array indices don't

Re: [HACKERS] Support for negative index values in array fetching

2011-01-05 Thread Peter Eisentraut
On sön, 2011-01-02 at 12:47 +0100, Florian Pflug wrote: > > Here's a patch to add support for negative index values in fetching > > elements from an array. > > That won't work. In SQL, array indices don't necessarily start with 0 (or 1, > or *any* > single value). FYI, this is true for PostgreS

Re: [HACKERS] Support for negative index values in array fetching

2011-01-02 Thread Florian Pflug
On Jan2, 2011, at 11:45 , Valtonen, Hannu wrote: > I ran into the problem of getting the last n elements out of an array and > while some workarounds do exist: > (http://stackoverflow.com/questions/2949881/getting-the-last-element-of-a-postgres-array-declaratively) > I was still annoyed that I co

[HACKERS] Support for negative index values in array fetching

2011-01-02 Thread Valtonen, Hannu
Hi, I ran into the problem of getting the last n elements out of an array and while some workarounds do exist: (http://stackoverflow.com/questions/2949881/getting-the-last-element-of-a-postgres-array-declaratively) I was still annoyed that I couldn't just ask for the last n values in an array