Downgrade implicit casts to text to be assignment-only, except for the ones
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 5 Jun 2007 21:31:09 +0000 (21:31 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 5 Jun 2007 21:31:09 +0000 (21:31 +0000)
commit31edbadf4af45dd4eecebcb732702ec6d7ae1819
treeb1b29b079deac806537bc3d5287f4eb325f48efa
parent1120b99445a90ceba27f49e5cf86293f0628d06a
Downgrade implicit casts to text to be assignment-only, except for the ones
from the other string-category types; this eliminates a lot of surprising
interpretations that the parser could formerly make when there was no directly
applicable operator.

Create a general mechanism that supports casts to and from the standard string
types (text,varchar,bpchar) for *every* datatype, by invoking the datatype's
I/O functions.  These new casts are assignment-only in the to-string direction,
explicit-only in the other, and therefore should create no surprising behavior.
Remove a bunch of thereby-obsoleted datatype-specific casting functions.

The "general mechanism" is a new expression node type CoerceViaIO that can
actually convert between *any* two datatypes if their external text
representations are compatible.  This is more general than needed for the
immediate feature, but might be useful in plpgsql or other places in future.

This commit does nothing about the issue that applying the concatenation
operator || to non-text types will now fail, often with strange error messages
due to misinterpreting the operator as array concatenation.  Since it often
(not always) worked before, we should either make it succeed or at least give
a more user-friendly error; but details are still under debate.

Peter Eisentraut and Tom Lane
60 files changed:
contrib/cube/README.cube
contrib/cube/cube.c
contrib/cube/cube.sql.in
contrib/cube/expected/cube.out
contrib/cube/expected/cube_1.out
contrib/cube/expected/cube_2.out
contrib/cube/sql/cube.sql
contrib/cube/uninstall_cube.sql
contrib/isn/isn.c
contrib/isn/isn.h
contrib/isn/isn.sql.in
doc/src/sgml/catalogs.sgml
doc/src/sgml/ref/create_cast.sgml
doc/src/sgml/syntax.sgml
doc/src/sgml/typeconv.sgml
src/backend/catalog/dependency.c
src/backend/executor/execQual.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/nodes/outfuncs.c
src/backend/nodes/readfuncs.c
src/backend/optimizer/path/costsize.c
src/backend/optimizer/util/clauses.c
src/backend/parser/parse_coerce.c
src/backend/parser/parse_expr.c
src/backend/parser/parse_func.c
src/backend/utils/Gen_fmgrtab.sh
src/backend/utils/adt/bool.c
src/backend/utils/adt/date.c
src/backend/utils/adt/enum.c
src/backend/utils/adt/float.c
src/backend/utils/adt/int.c
src/backend/utils/adt/int8.c
src/backend/utils/adt/mac.c
src/backend/utils/adt/network.c
src/backend/utils/adt/numeric.c
src/backend/utils/adt/oid.c
src/backend/utils/adt/regproc.c
src/backend/utils/adt/ri_triggers.c
src/backend/utils/adt/ruleutils.c
src/backend/utils/adt/timestamp.c
src/backend/utils/adt/uuid.c
src/include/catalog/catversion.h
src/include/catalog/pg_cast.h
src/include/catalog/pg_proc.h
src/include/nodes/execnodes.h
src/include/nodes/nodes.h
src/include/nodes/primnodes.h
src/include/parser/parse_coerce.h
src/include/utils/builtins.h
src/include/utils/date.h
src/include/utils/int8.h
src/include/utils/timestamp.h
src/pl/plpgsql/src/pl_exec.c
src/test/regress/expected/foreign_key.out
src/test/regress/expected/strings.out
src/test/regress/expected/subselect.out
src/test/regress/sql/foreign_key.sql
src/test/regress/sql/strings.sql
src/test/regress/sql/subselect.sql