Downgrade implicit casts to text to be assignment-only, except for the ones

Tom Lane <tgl@sss.pgh.pa.us>

Commit: 31edbadf4af45dd4eecebcb732702ec6d7ae1819
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2007-06-05T21:31:09Z
Releases: 8.3.0
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

Files

PathChange+/−
contrib/cube/cube.c modified +1 −13
contrib/cube/cube.sql.in modified +0 −10
contrib/cube/expected/cube_1.out modified +1 −1
contrib/cube/expected/cube_2.out modified +1 −1
contrib/cube/expected/cube.out modified +1 −1
contrib/cube/README.cube modified +0 −4
contrib/cube/sql/cube.sql modified +1 −1
contrib/cube/uninstall_cube.sql modified +0 −4
contrib/isn/isn.c modified +1 −84
contrib/isn/isn.h modified +1 −8
contrib/isn/isn.sql.in modified +1 −86
doc/src/sgml/catalogs.sgml modified +14 −3
doc/src/sgml/ref/create_cast.sgml modified +76 −31
doc/src/sgml/syntax.sgml modified +22 −17
doc/src/sgml/typeconv.sgml modified +49 −35
src/backend/catalog/dependency.c modified +9 −1
src/backend/executor/execQual.c modified +58 −1
src/backend/nodes/copyfuncs.c modified +19 −1
src/backend/nodes/equalfuncs.c modified +22 −1
src/backend/nodes/outfuncs.c modified +14 −1
src/backend/nodes/readfuncs.c modified +18 −1
src/backend/optimizer/path/costsize.c modified +18 −1
src/backend/optimizer/util/clauses.c modified +67 −1
src/backend/parser/parse_coerce.c modified +156 −78
src/backend/parser/parse_expr.c modified +5 −1
src/backend/parser/parse_func.c modified +45 −27
src/backend/utils/adt/bool.c modified +4 −15
src/backend/utils/adt/date.c modified +1 −176
src/backend/utils/adt/enum.c modified +48 −106
src/backend/utils/adt/float.c modified +1 −103
src/backend/utils/adt/int8.c modified +1 −43
src/backend/utils/adt/int.c modified +1 −65
src/backend/utils/adt/mac.c modified +1 −54
src/backend/utils/adt/network.c modified +6 −31
src/backend/utils/adt/numeric.c modified +1 −45
src/backend/utils/adt/oid.c modified +4 −46
src/backend/utils/adt/regproc.c modified +5 −1
src/backend/utils/adt/ri_triggers.c modified +18 −10
src/backend/utils/adt/ruleutils.c modified +25 −1
src/backend/utils/adt/timestamp.c modified +1 −182
src/backend/utils/adt/uuid.c modified +1 −30
src/backend/utils/Gen_fmgrtab.sh modified +2 −2
src/include/catalog/catversion.h modified +2 −2
src/include/catalog/pg_cast.h modified +27 −123
src/include/catalog/pg_proc.h modified +25 −101
src/include/nodes/execnodes.h modified +14 −1
src/include/nodes/nodes.h modified +3 −1
src/include/nodes/primnodes.h modified +19 −1
src/include/parser/parse_coerce.h modified +18 −6
src/include/utils/builtins.h modified +1 −22
src/include/utils/date.h modified +1 −7
src/include/utils/int8.h modified +1 −4
src/include/utils/timestamp.h modified +1 −7
src/pl/plpgsql/src/pl_exec.c modified +4 −1
src/test/regress/expected/foreign_key.out modified +5 −4
src/test/regress/expected/strings.out modified +1 −1
src/test/regress/expected/subselect.out modified +1 −1
src/test/regress/sql/foreign_key.sql modified +3 −3
src/test/regress/sql/strings.sql modified +1 −1
src/test/regress/sql/subselect.sql modified +1 −1