From: Tom Lane <tgl@sss.pgh.pa.us>
To: Piotr Findeisen <piotr.findeisen@starburstdata.com>
Cc: pgsql-general@postgresql.org
Subject: Re: Is _<typename> a supported way to create a column of array type?
Date: Fri, 26 Apr 2019 10:11:19 -0400
Message-ID: <31432.1556287879@sss.pgh.pa.us> (raw)
In-Reply-To: <CAMrFzbvjWgjUuvRCz9b1ukQrwLU3P8SG_D4vZcHF-rOyWxKO1A@mail.gmail.com>
References: <CAMrFzbt_DjD1BSLOhAUgNApu8MV3CCPmbEac9FfMxOOq6GAD0g@mail.gmail.com>
<31659.1556226223@sss.pgh.pa.us>
<CAMrFzbtAzyrQy0CSj8T1tCTJvFQKJ1ZYm2bJpRcFBqns4Tz5Vg@mail.gmail.com>
<32678.1556228173@sss.pgh.pa.us>
<CAMrFzbvjWgjUuvRCz9b1ukQrwLU3P8SG_D4vZcHF-rOyWxKO1A@mail.gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, piotr.findeisen@starburstdata.com
Subject: Re: Is _<typename> a supported way to create a column of array type?
In-Reply-To: <31432.1556287879@sss.pgh.pa.us>
References: <CAMrFzbt_DjD1BSLOhAUgNApu8MV3CCPmbEac9FfMxOOq6GAD0g@mail.gmail.com> <31659.1556226223@sss.pgh.pa.us> <CAMrFzbtAzyrQy0CSj8T1tCTJvFQKJ1ZYm2bJpRcFBqns4Tz5Vg@mail.gmail.com> <32678.1556228173@sss.pgh.pa.us> <CAMrFzbvjWgjUuvRCz9b1ukQrwLU3P8SG_D4vZcHF-rOyWxKO1A@mail.gmail.com> <31432.1556287879@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox