From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Kevin Grittner <kgrittn(at)ymail(dot)com> |
Cc: | Jeff Davis <pgsql(at)j-davis(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Postgres-Bugs <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: Failure to coerce unknown type to specific type |
Date: | 2015-05-03 18:42:47 |
Message-ID: | 22462.1430678567@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-hackers |
Kevin Grittner <kgrittn(at)ymail(dot)com> writes:
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Jeff Davis <pgsql(at)j-davis(dot)com> writes:
>>> So, what would happen for something like:
>>> select u+i from (select '1' as u, '2'::int as i) s;
>> I don't think there's any useful alternative to failing on this
>> type of case. You can't realistically postpone resolution of the
>> subquery output types long enough for outer-level expression
>> resolution to provide context.
> According to SQL Fiddle: MySQL, SQL Lite, and MS SQL Server all
> come up with 3 as the answer.
Really? The :: syntax is a Postgres-ism, so you surely didn't test
this query on those.
>> Even if you could, the behavior wouldn't be very well defined,
>> because (as you note) there might be more than one such
>> expression leading to contradictory results.
> Do you have a simple example of what you mean?
Jeff already pointed out the issue, but consider
select u+i from (select '1' as u, '2'::int as i) s where u<'foo'::text;
At the very least such a query would behave differently depending on
whether we process the outer query's WHERE clause before or after its
SELECT output list.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Kevin Grittner | 2015-05-03 18:56:14 | Re: Failure to coerce unknown type to specific type |
Previous Message | Kevin Grittner | 2015-05-03 18:28:07 | Re: Failure to coerce unknown type to specific type |
From | Date | Subject | |
---|---|---|---|
Next Message | Kevin Grittner | 2015-05-03 18:56:14 | Re: Failure to coerce unknown type to specific type |
Previous Message | Kevin Grittner | 2015-05-03 18:28:07 | Re: Failure to coerce unknown type to specific type |