Re: column "b" is of type X but expression is of type text - Mailing list pgsql-hackers

From Tom Lane
Subject Re: column "b" is of type X but expression is of type text
Date
Msg-id 1967.1373678283@sss.pgh.pa.us
Whole thread Raw
In response to Re: column "b" is of type X but expression is of type text  (Josh Berkus <josh@agliodbs.com>)
List pgsql-hackers
Josh Berkus <josh@agliodbs.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



pgsql-hackers by date:

Previous
From: Josh Berkus
Date:
Subject: --with-libedit-preferred is bad design
Next
From: Tom Lane
Date:
Subject: Re: --with-libedit-preferred is bad design