From: | "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Decibel! <decibel(at)decibel(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Proposal: new function array_init |
Date: | 2008-06-04 21:41:07 |
Message-ID: | 162867790806041441y6b6ea65aw4a0f3b2d6fd390@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
2008/6/4 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> 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 is in assignment
next question:
when I declare function only for anyelement, I can't simply create text array
CREATE OR REPLACE FUNCTION array_fill(dv anyelement, dims int[])
RETURNS anyarray
AS 'MODULE_PATHNAME', 'array_fill'
LANGUAGE C IMMUTABLE;
postgres=# select array_fill(1,array[4,4]);
array_fill
-------------------------------------------
{{1,1,1,1},{1,1,1,1},{1,1,1,1},{1,1,1,1}}
(1 row)
Time: 1,369 ms
postgres=# select array_fill('p',array[4,4]);
ERROR: could not determine polymorphic type because input has type "unknown"
I can use hack:
CREATE OR REPLACE FUNCTION array_fill(dv text, dims int[])
RETURNS text[]
AS 'MODULE_PATHNAME', 'array_fill'
LANGUAGE C IMMUTABLE;
postgres=# select array_fill('p',array[4,4]);
array_fill
-------------------------------------------
{{p,p,p,p},{p,p,p,p},{p,p,p,p},{p,p,p,p}}
(1 row)
what do you thing about it?
regards
Pavel Stehule
> regards, tom lane
>
From | Date | Subject | |
---|---|---|---|
Next Message | David E. Wheeler | 2008-06-04 21:57:28 | Re: Overhauling GUCS |
Previous Message | Tom Lane | 2008-06-04 21:34:48 | Re: Proposal: new function array_init |