X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 46E565292B; Mon, 6 Jun 2005 11:17:40 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90508-03; Mon, 6 Jun 2005 14:17:35 +0000 (GMT) Received: from web11.manitu.net (web11.manitu.net [217.11.48.111]) by svr1.postgresql.org (Postfix) with ESMTP id B7EDE52921; Mon, 6 Jun 2005 11:17:33 -0300 (ADT) Received: from dicaprio.akademie1.de (dicaprio.akademie1.de [62.165.4.166]) (authenticated) by web11.manitu.net (8.10.2-SOL3/8.10.2) with ESMTP id j56EHUT14790; Mon, 6 Jun 2005 16:17:30 +0200 Subject: Re: ARRAY() returning NULL instead of ARRAY[] resp. {} From: Markus Bertheau =?UTF-8?Q?=E2=98=AD?= To: Tom Lane Cc: Joe Conway , pgsql-sql@postgresql.org, pgsql-hackers@postgresql.org In-Reply-To: <16774.1116907560@sss.pgh.pa.us> References: <1116873219.7306.0.camel@localhost.localdomain> <42923762.7010708@joeconway.com> <16774.1116907560@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8 Date: Mon, 06 Jun 2005 16:17:24 +0200 Message-Id: <1118067445.5506.6.camel@dicaprio.akademie1.de> Mime-Version: 1.0 X-Mailer: Evolution 2.0.4 (2.0.4-4) Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.019 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/78 X-Sequence-Number: 21679 В Втр, 24/05/2005 в 00:06 -0400, Tom Lane пишет: > Joe Conway writes: > > Markus Bertheau wrote: > >> why does SELECT ARRAY(SELECT 1 WHERE FALSE) return NULL instead of > >> ARRAY[] resp. '{}'? > > > Why would you expect an empty array instead of a NULL? > > I think he's got a good point, actually. We document the ARRAY-with- > parens-around-a-SELECT syntax as > > The resulting one-dimensional array will have an element for > each row in the subquery result, with an element type matching > that of the subquery's output column. > > To me, that implies that a subquery result of no rows generates a > one-dimensional array of no elements, not a null array. By analogy, array_upper('{}'::TEXT[], 1) should return 0 instead of NULL. Markus -- Markus Bertheau ☭