Re: [HACKERS] Proposal: new function array_init

2008-06-04 Thread Decibel!
On Jun 2, 2008, at 11:46 AM, Tom Lane wrote: * Should the fill value be the first parameter instead of the last? +1. The other way just seems weird, at least to me. -- Decibel!, aka Jim C. Nasby, Database Architect [EMAIL PROTECTED] Give your computer some brain candy! www.distributed.net

Re: [HACKERS] Proposal: new function array_init

2008-06-04 Thread Pavel Stehule
2008/6/4 Decibel! [EMAIL PROTECTED]: On Jun 2, 2008, at 11:46 AM, Tom Lane wrote: * Should the fill value be the first parameter instead of the last? +1. The other way just seems weird, at least to me. can you write reason? I put fill value on end, because it is like default value:

Re: [HACKERS] Proposal: new function array_init

2008-06-04 Thread Tom Lane
Pavel Stehule [EMAIL PROTECTED] writes: I put fill value on end, because it is like default value: array_set(array[2,2]); array_set(array[2,2], 0); Huh? That's completely nonsensical ... where will you determine the type of the array, if you don't have a sample element? The fact that the

Re: [HACKERS] Proposal: new function array_init

2008-06-04 Thread Pavel Stehule
2008/6/4 Tom Lane [EMAIL PROTECTED]: Pavel Stehule [EMAIL PROTECTED] writes: I put fill value on end, because it is like default value: array_set(array[2,2]); array_set(array[2,2], 0); Huh? That's completely nonsensical ... where will you determine the type of the array, if you don't have

Re: [HACKERS] Proposal: new function array_init

2008-06-04 Thread Tom Lane
Pavel Stehule [EMAIL PROTECTED] writes: 2008/6/4 Tom Lane [EMAIL PROTECTED]: Huh? That's completely nonsensical ... where will you determine the type of the array, if you don't have a sample element? it is nonsens in current postgres. But null array is castable to anyarray no? If you mean

Re: [HACKERS] Proposal: new function array_init

2008-06-04 Thread Pavel Stehule
2008/6/4 Tom Lane [EMAIL PROTECTED]: Pavel Stehule [EMAIL PROTECTED] writes: 2008/6/4 Tom Lane [EMAIL PROTECTED]: Huh? That's completely nonsensical ... where will you determine the type of the array, if you don't have a sample element? it is nonsens in current postgres. But null array is

Re: [HACKERS] Proposal: new function array_init

2008-06-04 Thread Andrew Dunstan
Tom Lane wrote: Pavel Stehule [EMAIL PROTECTED] writes: 2008/6/4 Tom Lane [EMAIL PROTECTED]: Huh? That's completely nonsensical ... where will you determine the type of the array, if you don't have a sample element? it is nonsens in current postgres. But null array is

Re: [HACKERS] Proposal: new function array_init

2008-06-04 Thread Tom Lane
Pavel Stehule [EMAIL PROTECTED] writes: 2008/6/4 Tom Lane [EMAIL PROTECTED]: If you mean an array of nulls, it still has to have an element type. I know it - but there was discus about untyped array for empty arrays like ARRAY[] What's that have to do with array_init? It will not (usually)

Re: [HACKERS] Proposal: new function array_init

2008-06-04 Thread Pavel Stehule
2008/6/4 Tom Lane [EMAIL PROTECTED]: Pavel Stehule [EMAIL PROTECTED] writes: 2008/6/4 Tom Lane [EMAIL PROTECTED]: If you mean an array of nulls, it still has to have an element type. I know it - but there was discus about untyped array for empty arrays like ARRAY[] What's that have to do

Re: [HACKERS] Proposal: new function array_init

2008-06-04 Thread Tom Lane
Pavel Stehule [EMAIL PROTECTED] writes: idealized code: a = array_set(array[10,10]); // untyped null array a[10,10] = 'text'; -- now array is typed And how did you declare 'a'? This seems like a solution in search of a problem. regards, tom lane -- Sent via

Re: [HACKERS] Proposal: new function array_init

2008-06-04 Thread Pavel Stehule
2008/6/4 Tom Lane [EMAIL PROTECTED]: Pavel Stehule [EMAIL PROTECTED] writes: idealized code: a = array_set(array[10,10]); // untyped null array a[10,10] = 'text'; -- now array is typed And how did you declare 'a'? This seems like a solution in search of a problem. you have true - problem

Re: [HACKERS] Proposal: new function array_init

2008-06-04 Thread Tom Lane
Pavel Stehule [EMAIL PROTECTED] writes: postgres=# select array_fill('p',array[4,4]); ERROR: could not determine polymorphic type because input has type unknown [ shrug... ] I don't really see a problem with that. I can use hack: CREATE OR REPLACE FUNCTION array_fill(dv text, dims int[])

Re: [HACKERS] Proposal: new function array_init

2008-06-04 Thread Pavel Stehule
2008/6/5 Tom Lane [EMAIL PROTECTED]: Pavel Stehule [EMAIL PROTECTED] writes: postgres=# select array_fill('p',array[4,4]); ERROR: could not determine polymorphic type because input has type unknown [ shrug... ] I don't really see a problem with that. you have t cast in most common case

[HACKERS] Proposal: new function array_init

2008-06-02 Thread Pavel Stehule
Hello There was more time questions about array's initialisation. I propose function array_init. CREATE OR REPLACE FUNCTION array_init(sizes int[], v anyelement) RETURNS anyarray; First parameter is array of dimension's sizes. Second argument is value that will be used for initialisation.

Re: [HACKERS] Proposal: new function array_init

2008-06-02 Thread Tom Lane
Pavel Stehule [EMAIL PROTECTED] writes: There was more time questions about array's initialisation. I propose function array_init. CREATE OR REPLACE FUNCTION array_init(sizes int[], v anyelement) RETURNS anyarray; I think this is basically a good idea, but maybe the API needs a bit of

Re: [HACKERS] Proposal: new function array_init

2008-06-02 Thread Webb Sprague
On Mon, Jun 2, 2008 at 9:46 AM, Tom Lane [EMAIL PROTECTED] wrote: Pavel Stehule [EMAIL PROTECTED] writes: There was more time questions about array's initialisation. I propose function array_init. As one of the questioners, I will give some short thoughts below. CREATE OR REPLACE FUNCTION

Re: [HACKERS] Proposal: new function array_init

2008-06-02 Thread Pavel Stehule
2008/6/2 Tom Lane [EMAIL PROTECTED]: Pavel Stehule [EMAIL PROTECTED] writes: There was more time questions about array's initialisation. I propose function array_init. CREATE OR REPLACE FUNCTION array_init(sizes int[], v anyelement) RETURNS anyarray; I think this is basically a good idea,

Re: [HACKERS] Proposal: new function array_init

2008-06-02 Thread James William Pye
On Mon, Jun 02, 2008 at 08:10:19PM +0200, Pavel Stehule wrote: * I have a mild preference for array_fill instead of array_init. maybe, maybe array_set. Any ideas are welcome array_create? -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your