Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1atR17-0007Vg-NA for pgsql-general@arkaria.postgresql.org; Fri, 22 Apr 2016 02:40:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1atR17-0001rs-8m for pgsql-general@arkaria.postgresql.org; Fri, 22 Apr 2016 02:40:25 +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_2) (envelope-from ) id 1atQyo-0007eA-NB for pgsql-general@postgresql.org; Fri, 22 Apr 2016 02:38:02 +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_2) (envelope-from ) id 1atQyh-0003C9-MX for pgsql-general@postgresql.org; Fri, 22 Apr 2016 02:38:01 +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 u3M2brn3014072; Thu, 21 Apr 2016 22:37:53 -0400 From: Tom Lane To: Scott Ribe cc: Postgresql General Subject: Re: different empty array syntax requirements In-reply-to: References: Comments: In-reply-to Scott Ribe message dated "Thu, 21 Apr 2016 20:20:13 -0600" Date: Thu, 21 Apr 2016 22:37:53 -0400 Message-ID: <14071.1461292673@sss.pgh.pa.us> X-Pg-Spam-Score: -2.9 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org Scott Ribe writes: > How is that one pgsql build (both are 9.5.2) has different casting behavior for empty arrays: > pedcard=# select (ARRAY[])::text[]; > ERROR: cannot determine type of empty array > LINE 1: select (ARRAY[])::text[]; > ^ > HINT: Explicitly cast to the desired type, for example ARRAY[]::integer[]. ... wtf? [ thinks for awhile ... ] Oh! I bet this explains it: regression=# select (ARRAY[])::text[]; array ------- {} (1 row) regression=# set operator_precedence_warning = on; SET regression=# select (ARRAY[])::text[]; ERROR: cannot determine type of empty array LINE 1: select (ARRAY[])::text[]; ^ HINT: Explicitly cast to the desired type, for example ARRAY[]::integer[]. The parens turn into an actual parsetree node when operator_precedence_warning is on, and the cast-of-an-array hack doesn't know it should look through such a node. That's a bug. Will fix it. regards, tom lane -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general