Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZD9uV-0003qf-C0 for pgsql-docs@arkaria.postgresql.org; Thu, 09 Jul 2015 11:22:35 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZD9uU-0008A8-0F for pgsql-docs@arkaria.postgresql.org; Thu, 09 Jul 2015 11:22:34 +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) (envelope-from ) id 1ZCzkD-0005Cc-AW for pgsql-docs@postgresql.org; Thu, 09 Jul 2015 00:31:17 +0000 Received: from mail.hemio.de ([144.76.93.186]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZCzk8-0001N8-Ov for pgsql-docs@postgresql.org; Thu, 09 Jul 2015 00:31:16 +0000 X-Original-To-Masked: Received: from user.client (localhost [144.76.93.186]) by mail.hemio.de (Postfix) with ESMTPSA id 0566186 for ; Thu, 9 Jul 2015 02:31:10 +0200 (CEST) Message-ID: <559DC0CE.90900@hemio.de> Date: Thu, 09 Jul 2015 02:31:10 +0200 From: Michael Herold User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-Version: 1.0 To: pgsql-docs@postgresql.org Subject: ARRAY[1] || NULL <> array_append(ARRAY[1], NULL) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -4.9 (----) 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 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. 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]. Combined with the example of NULL || ARRAY[1,2] the underlying principle becomes clear to me. Strings behave different, but maybe this is also a potential pitfall: SELECT 'abc' || NULL, concat('abc', NULL); ?column? | concat ----------+-------- (NULL) | abc Best, Michael [Table 9-45]: -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs