git.postgresql.org Git - postgresql.git/commit

git projects / postgresql.git / commit
? search:
summary | shortlog | log | commit | commitdiff | tree
(parent: fab13dc) | patch
Introduce "anycompatible" family of polymorphic types.
2020年3月19日 15:43:11 +0000 (11:43 -0400)
2020年3月19日 15:43:11 +0000 (11:43 -0400)
commit 24e2885ee304cb6a94fdfc25a1a108344ed9f4f7
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
33 files changed:
doc/src/sgml/datatype.sgml diff | blob | blame | history
doc/src/sgml/extend.sgml diff | blob | blame | history
doc/src/sgml/plpgsql.sgml diff | blob | blame | history
doc/src/sgml/xfunc.sgml diff | blob | blame | history
src/backend/catalog/index.c diff | blob | blame | history
src/backend/catalog/pg_proc.c diff | blob | blame | history
src/backend/commands/functioncmds.c diff | blob | blame | history
src/backend/parser/parse_coerce.c diff | blob | blame | history
src/backend/utils/adt/json.c diff | blob | blame | history
src/backend/utils/adt/jsonb.c diff | blob | blame | history
src/backend/utils/adt/pseudotypes.c diff | blob | blame | history
src/backend/utils/fmgr/funcapi.c diff | blob | blame | history
src/include/catalog/catversion.h diff | blob | blame | history
src/include/catalog/pg_proc.dat diff | blob | blame | history
src/include/catalog/pg_type.dat diff | blob | blame | history
src/include/catalog/pg_type.h diff | blob | blame | history
src/pl/plpgsql/src/pl_comp.c diff | blob | blame | history
src/test/regress/expected/aggregates.out diff | blob | blame | history
src/test/regress/expected/create_aggregate.out diff | blob | blame | history
src/test/regress/expected/opr_sanity.out diff | blob | blame | history
src/test/regress/expected/plpgsql.out diff | blob | blame | history
src/test/regress/expected/polymorphism.out diff | blob | blame | history
src/test/regress/expected/rangefuncs.out diff | blob | blame | history
src/test/regress/expected/rangetypes.out diff | blob | blame | history
src/test/regress/expected/type_sanity.out diff | blob | blame | history
src/test/regress/sql/aggregates.sql diff | blob | blame | history
src/test/regress/sql/create_aggregate.sql diff | blob | blame | history
src/test/regress/sql/opr_sanity.sql diff | blob | blame | history
src/test/regress/sql/plpgsql.sql diff | blob | blame | history
src/test/regress/sql/polymorphism.sql diff | blob | blame | history
src/test/regress/sql/rangefuncs.sql diff | blob | blame | history
src/test/regress/sql/rangetypes.sql diff | blob | blame | history
src/test/regress/sql/type_sanity.sql diff | blob | blame | history
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /