Re: Is _ a supported way to create a column of array type? - Mailing list pgsql-general

From Tom Lane
Subject Re: Is _ a supported way to create a column of array type?
Date
Msg-id 31432.1556287879@sss.pgh.pa.us
Whole thread Raw
In response to Re: Is _ a supported way to create a column of array type?  (Piotr Findeisen <piotr.findeisen@starburstdata.com>)
List 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 by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: 9.6.9 Default configuration for a default installation butdifferent with-krb-srvnam
Next
From: Tom Lane
Date:
Subject: Re: TCP Resets when closing connection opened via SSL