Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Piotr Findeisen <piotr.findeisen@xxxxxxxxxxxxxxxxx> 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





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux