Re: [BUGS] Failure to coerce unknown type to specific type

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [BUGS] Failure to coerce unknown type to specific type
Date: 2015-04-23 17:22:19
Message-ID: CAMp0ubehp_j16rhLLuNhut6iVkdaGZyJ2F3u0sRk5wtvCwMCvg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Thu, Apr 23, 2015 at 1:49 AM, David G. Johnston
<david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
> Reading and writing all this I'm convinced you have gotten the idea in your
> mind an expectation of equivalency and consistency where there really is
> little or none from an overall design perspective. And none insofar as
> would merit trying to force the two example queries you provide to behave
> identically. There are a number of things about SQL that one either simply
> lives with or goes through mind contortions to understand the, possibly
> imperfect, reasoning behind. This is one of those things: and while it's
> been fun to do those contortions in the end I am only a little bit better
> off than when I simply accepted the fact the unknown and untyped were
> similar but different (even if I hadn't considered giving them different
> names).

You make some good points, but I disagree for two reasons:

1. This is a postgres issue, not a general SQL issue, so we can't
simply say "SQL is weird" (like we can with a lot of the strange NULL
semantics).
2. Postgres has determined that the unknown column reference "b" in
the query "SELECT a=b FROM (SELECT ''::text, ' ') x(a,b)" can and
should be coerced to text. So postgres has already made that decision.
It's just that when it tries to coerce it, it fails. Even if you
believe that literals and column references are not equivalent, I
don't see any justification at all for this behavior -- postgres
should not decide to coerce it in the first place if it's going to
fail.

Regards,
Jeff Davis

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2015-04-23 17:39:53 Re: [BUGS] Failure to coerce unknown type to specific type
Previous Message Robert Haas 2015-04-23 17:18:32 Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Janes 2015-04-23 17:22:31 Re: improving speed of make check-world
Previous Message Heikki Linnakangas 2015-04-23 17:17:03 Re: adding more information about process(es) cpu and memory usage