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 B3B66528AD for ; Tue, 24 May 2005 03:36:58 -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 42268-05 for ; Tue, 24 May 2005 06:36:53 +0000 (GMT) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) by svr1.postgresql.org (Postfix) with ESMTP id A18025287C for ; Tue, 24 May 2005 03:36:51 -0300 (ADT) Received: from matrix.gatewaynet.com (localhost.localdomain [127.0.0.1]) by matrix.gatewaynet.com (8.12.8/8.12.8) with ESMTP id j4O6LI9W010990; Tue, 24 May 2005 09:21:18 +0300 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.8/8.12.8/Submit) with ESMTP id j4O6LI17010986; Tue, 24 May 2005 09:21:18 +0300 Date: Tue, 24 May 2005 09:21:18 +0300 (EEST) From: Achilleus Mantzios To: Joe Conway Cc: Markus Bertheau , Subject: Re: ARRAY() returning NULL instead of ARRAY[] resp. {} In-Reply-To: <42923762.7010708@joeconway.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-7 Content-Transfer-Encoding: 8BIT X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/196 X-Sequence-Number: 21509 O Joe Conway έγραψε στις May 23, 2005 : > 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? NULL is what > you'd get for other data types -- for example: One could ask in the same fashion why someone would want a table if this table contains no rows. A null value may mean "dont know", wheras a '{}' (empty) value may mean "empty set". For instance lets consider the case where an array holds the factors of a polynomial formula. An null value might mean that the person defining the formulas haven't been bothered with this one yet. An empty value might mean that the person indicates that has worked on this particular one, but he/she has no data yet. Ok extreme cases, but to me there is a clean distinction between a null array and an empty array. Also what is definately needed is arrays that may contain null values. > > regression=# SELECT (SELECT 1 WHERE FALSE) IS NULL; > ?column? > ---------- > t > (1 row) > > Joe > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq > -- -Achilleus