Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZDCNt-0002NM-3G for pgsql-docs@arkaria.postgresql.org; Thu, 09 Jul 2015 14:01:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZDCNs-0001gy-KL for pgsql-docs@arkaria.postgresql.org; Thu, 09 Jul 2015 14:01:04 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZDCNs-0001gs-29 for pgsql-docs@postgresql.org; Thu, 09 Jul 2015 14:01:04 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZDCNp-0001OC-Ej for pgsql-docs@postgresql.org; Thu, 09 Jul 2015 14:01:02 +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 t69E0vDA032403; Thu, 9 Jul 2015 10:00:58 -0400 From: Tom Lane To: Michael Herold cc: pgsql-docs@postgresql.org Subject: Re: ARRAY[1] || NULL <> array_append(ARRAY[1], NULL) In-reply-to: <559DC0CE.90900@hemio.de> References: <559DC0CE.90900@hemio.de> Comments: In-reply-to Michael Herold message dated "Thu, 09 Jul 2015 02:31:10 +0200" Date: Thu, 09 Jul 2015 10:00:57 -0400 Message-ID: <32402.1436450457@sss.pgh.pa.us> X-Pg-Spam-Score: -2.2 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org Michael Herold writes: > A few minutes ago I got bitten by the following PostgreSQL (9.4) behavior > SELECT ARRAY[1] || NULL, array_append(ARRAY[1], NULL); > ?column? | array_append > ----------+-------------- > {1} | {1,NULL} > I expected that array_append and || are equivalent in this case but > obviously they are not. Yeah, the first case turns out to be array_cat not array_append. > Sure, this is not too surprising since "||" has > to guess which operation is appropriate. However, I would have highly > appreciated ARRAY[1,2] || NULL as an example in [Table 9-45]. Hm. I don't think there is really room for such an example in that table, and certainly not room for a discursive discussion. What would make more sense to me is to add a paragraph and example concerning this issue at the bottom of section 8.15.4, right after array_append and array_cat are introduced. Since there's already a pointer to 8.15 just below that table, people would hopefully find the example from that vicinity as well. Seem reasonable? regards, tom lane -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs