It would be nice if you'd follow the list convention of bottom-posting. Not doing that is much more annoying than the omission of version and o/s - especially the later since PostgreSQL purports to be generally o/s agnostic.
On Friday, March 4, 2016, Melvin Davidson <
melvin6925@xxxxxxxxx> wrote:
Probably because pg_typeof() returns the OID of a COLUMN in a table def.. Strings literals do not have oid's.
http://www.postgresql.org/docs/9.4/interactive/functions-info.html"pg_typeof
returns the OID of the
data type of the value that is passed to it. This can be helpful
for troubleshooting or dynamically constructing SQL queries. The
function is declared as returning
regtype,
which is an OID alias type (see
Section 8.18); this means that it is the
same as an OID for comparison purposes but displays as a type
name. For example:"
While true this doesn't actually answer the question - that being what's the motiviation for not implicitly casting away from unknown. I suspect that the main reason is that in an extensible system like PostgreSQL it is deemed risky to have too many implicit casts. Having one from unknown required the system to make decisions that could result in unexpected results that would be hard to catch without careful review of queries and results. It is an issue of some contention in the community but so far no one has convinced the committees to change how this works.
Please in the future, ALWAYS specify your PostgreSQL version and O/S, regardless of whether or not you thinnk it is pertinent.
But don't feel too bad if you forget...
David J.