Re: different empty array syntax requirements

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Scott Ribe <scott_ribe(at)elevated-dev(dot)com>
Cc: Postgresql General <pgsql-general(at)postgresql(dot)org>
Subject: Re: different empty array syntax requirements
Date: 2016-04-22 02:37:53
Message-ID: 14071.1461292673@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Scott Ribe <scott_ribe(at)elevated-dev(dot)com> 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message ralf.meyer 2016-04-22 04:06:24 Fw: new important message
Previous Message Alvaro Aguayo Garcia-Rada 2016-04-22 02:25:53 Re: different empty array syntax requirements