Re: Is _ a supported way to create a column of array type?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Is _ a supported way to create a column of array type?
Дата
Msg-id 31432.1556287879@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Is _ a supported way to create a column of array type?  (Piotr Findeisen <piotr.findeisen@starburstdata.com>)
Список pgsql-general
Piotr Findeisen <piotr.findeisen@starburstdata.com> writes:
> Do you have any plans to support arrays with different number of dimensions
> in the type system?

Mmm ... don't hold your breath.  People have speculated about that,
but I haven't seen any actual proposals, and it's hard to see how
we could do it without creating compatibility problems that would
outweigh the value of the feature.

In very late-model Postgres (I think just 11 and up) you can sort
of fake it by using arrays of domains:

regression=# create domain intarray as int4[];
CREATE DOMAIN
regression=# create table foo (f1 intarray[]);
CREATE TABLE
regression=# insert into foo values(array[array[4]]);
ERROR:  column "f1" is of type intarray[] but expression is of type integer[]
LINE 1: insert into foo values(array[array[4]]);
                               ^
HINT:  You will need to rewrite or cast the expression.
regression=# insert into foo values(array[array[4]::intarray]);
INSERT 0 1

But as this example shows, it's not exactly a transparent solution.
It might be possible to make this specific case work better, but
I think you'd inevitably end up needing lots of explicit casts.

            regards, tom lane



В списке pgsql-general по дате отправления:

Предыдущее
От: Laurenz Albe
Дата:
Сообщение: Re: 9.6.9 Default configuration for a default installation butdifferent with-krb-srvnam
Следующее
От: Tom Lane
Дата:
Сообщение: Re: TCP Resets when closing connection opened via SSL