Re: column "b" is of type X but expression is of type text

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: column "b" is of type X but expression is of type text
Date: 2013-07-13 01:18:03
Message-ID: 1967.1373678283@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Josh Berkus <josh(at)agliodbs(dot)com> writes:
> The root cause of this is that we treat "default TEXT" the same as "real
> TEXT" as a type.

No, we do not do that at all. A NULL is initially of type unknown, and
that is definitely not the same as text. The type resolution rules
treat the two cases differently.

The real cause of what David is complaining about is that we resolve
expression datatypes bottom up. Once we've determined that we're going
to consider foo(NULL) as an invocation of foo(text), that's what it is,
and the context won't cause us to go back and change that.

> Changing that logic, though, would require a massive
> refactoring and debugging of PostgreSQL.

This is true enough; and you forgot to mention all the existing
applications that would also need changes if we changed the expression
resolution rules. We could possibly make marginal changes without too
much pain, but making function resolution context-dependent would hardly
be a marginal change.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2013-07-13 01:31:42 Re: --with-libedit-preferred is bad design
Previous Message Josh Berkus 2013-07-13 01:04:39 --with-libedit-preferred is bad design