Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hK1ZX-0000yu-9I for pgsql-general@arkaria.postgresql.org; Fri, 26 Apr 2019 14:11:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hK1ZV-0005sU-QI for pgsql-general@arkaria.postgresql.org; Fri, 26 Apr 2019 14:11:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hK1ZV-0005s7-D3 for pgsql-general@lists.postgresql.org; Fri, 26 Apr 2019 14:11:25 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hK1ZS-0006fk-RL for pgsql-general@postgresql.org; Fri, 26 Apr 2019 14:11:24 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x3QEBJ43031433; Fri, 26 Apr 2019 10:11:19 -0400 From: Tom Lane To: Piotr Findeisen cc: pgsql-general@postgresql.org Subject: Re: Is _ a supported way to create a column of array type? In-reply-to: References: <31659.1556226223@sss.pgh.pa.us> <32678.1556228173@sss.pgh.pa.us> Comments: In-reply-to Piotr Findeisen message dated "Fri, 26 Apr 2019 12:50:01 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <31431.1556287879.1@sss.pgh.pa.us> Date: Fri, 26 Apr 2019 10:11:19 -0400 Message-ID: <31432.1556287879@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Piotr Findeisen 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