Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d0wmG-0003CS-1C for pgsql-bugs@arkaria.postgresql.org; Wed, 19 Apr 2017 21:04:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d0wmF-0005J6-H9 for pgsql-bugs@arkaria.postgresql.org; Wed, 19 Apr 2017 21:04:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d0wlZ-000457-Dr for pgsql-bugs@postgresql.org; Wed, 19 Apr 2017 21:03:57 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d0wlX-0007Gz-7Y for pgsql-bugs@postgresql.org; Wed, 19 Apr 2017 21:03:56 +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 v3JL3qDJ030752; Wed, 19 Apr 2017 17:03:52 -0400 From: Tom Lane To: david.g.johnston@gmail.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #14626: array_agg( anyarray ) unexpected error with multi-valued single-dimension array In-reply-to: <20170419204327.24366.56745@wrigleys.postgresql.org> References: <20170419204327.24366.56745@wrigleys.postgresql.org> Comments: In-reply-to david.g.johnston@gmail.com message dated "Wed, 19 Apr 2017 20:43:27 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <30750.1492635832.1@sss.pgh.pa.us> Date: Wed, 19 Apr 2017 17:03:52 -0400 Message-ID: <30751.1492635832@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org david.g.johnston@gmail.com writes: > This doesn't, and should since the number of elements in the non-empty array > shouldn't change the dimensionality logic. > SELECT array_agg(CASE WHEN a = ARRAY[]::text[] THEN ARRAY['N/A']::text[] > ELSE a END) > FROM ( VALUES (1, ARRAY[]::text[]), (1, ARRAY['1','2']::text[]) ) vals (v, > a) Why do you think that should work? You're asking array_agg to accumulate a 1-D length-1 array and then a 1-D length-2 array. There's no way to make a rectangular 2-D array out of that, except perhaps by inventing entries which isn't in array_agg's charter. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs