postgresql/src/backend/utils
Tom Lane 24e2885ee3 Introduce "anycompatible" family of polymorphic types.
This patch adds the pseudo-types anycompatible, anycompatiblearray,
anycompatiblenonarray, and anycompatiblerange.  They work much like
anyelement, anyarray, anynonarray, and anyrange respectively, except
that the actual input values need not match precisely in type.
Instead, if we can find a common supertype (using the same rules
as for UNION/CASE type resolution), then the parser automatically
promotes the input values to that type.  For example,
"myfunc(anycompatible, anycompatible)" can match a call with one
integer and one bigint argument, with the integer automatically
promoted to bigint.  With anyelement in the definition, the user
would have had to cast the integer explicitly.

The new types also provide a second, independent set of type variables
for function matching; thus with "myfunc(anyelement, anyelement,
anycompatible) returns anycompatible" the first two arguments are
constrained to be the same type, but the third can be some other
type, and the result has the type of the third argument.  The need
for more than one set of type variables was foreseen back when we
first invented the polymorphic types, but we never did anything
about it.

Pavel Stehule, revised a bit by me

Discussion: https://postgr.es/m/CAFj8pRDna7VqNi8gR+Tt2Ktmz0cq5G93guc3Sbn_NVPLdXAkqA@mail.gmail.com
2020-03-19 11:43:11 -04:00
..
adt Introduce "anycompatible" family of polymorphic types. 2020-03-19 11:43:11 -04:00
cache Introduce a maintenance_io_concurrency setting. 2020-03-16 17:14:26 +13:00
error Add backend type to csvlog and optionally log_line_prefix 2020-03-15 11:20:21 +01:00
fmgr Introduce "anycompatible" family of polymorphic types. 2020-03-19 11:43:11 -04:00
hash Move src/backend/utils/hash/hashfn.c to src/common 2020-02-27 09:25:41 +05:30
init Unify several ways to tracking backend type 2020-03-13 14:01:10 +01:00
mb Marginal comments and docs cleanup. 2020-03-10 17:34:09 -04:00
misc Disk-based Hash Aggregation. 2020-03-18 15:42:02 -07:00
mmgr Specialize MemoryContextMemAllocated(). 2020-03-18 15:39:14 -07:00
resowner Move src/backend/utils/hash/hashfn.c to src/common 2020-02-27 09:25:41 +05:30
sort Introduce LogicalTapeSetExtend(). 2020-03-09 10:40:02 -07:00
time Update copyrights for 2020 2020-01-01 12:21:45 -05:00
.gitignore Rearrange makefile rules for running Gen_fmgrtab.pl. 2018-05-03 17:54:18 -04:00
errcodes.txt Update copyrights for 2020 2020-01-01 12:21:45 -05:00
Gen_dummy_probes.pl Update copyrights for 2020 2020-01-01 12:21:45 -05:00
Gen_dummy_probes.sed Update copyrights for 2020 2020-01-01 12:21:45 -05:00
Gen_fmgrtab.pl Update copyrights for 2020 2020-01-01 12:21:45 -05:00
generate-errcodes.pl Update copyrights for 2020 2020-01-01 12:21:45 -05:00
Makefile Update copyrights for 2020 2020-01-01 12:21:45 -05:00
probes.d Update copyrights for 2020 2020-01-01 12:21:45 -05:00