2008/6/4 Tom Lane <tgl@sss.pgh.pa.us>:
> "Pavel Stehule" <pavel.stehule@gmail.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
>