Re: Proposal: new function array_init
| От | Pavel Stehule |
|---|---|
| Тема | Re: Proposal: new function array_init |
| Дата | |
| Msg-id | 162867790806041441y6b6ea65aw4a0f3b2d6fd390@mail.gmail.com обсуждение исходный текст |
| Ответ на | Re: Proposal: new function array_init (Tom Lane <tgl@sss.pgh.pa.us>) |
| Ответы |
Re: Proposal: new function array_init
|
| Список | pgsql-hackers |
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
>
В списке pgsql-hackers по дате отправления: