pgsql: Improve handling of domains over arrays.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Improve handling of domains over arrays.
Дата
Msg-id E1P91Qu-00051Q-Mx@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Improve handling of domains over arrays.

This patch eliminates various bizarre behaviors caused by sloppy thinking
about the difference between a domain type and its underlying array type.
In particular, the operation of updating one element of such an array
has to be considered as yielding a value of the underlying array type,
*not* a value of the domain, because there's no assurance that the
domain's CHECK constraints are still satisfied.  If we're intending to
store the result back into a domain column, we have to re-cast to the
domain type so that constraints are re-checked.

For similar reasons, such a domain can't be blindly matched to an ANYARRAY
polymorphic parameter, because the polymorphic function is likely to apply
array-ish operations that could invalidate the domain constraints.  For the
moment, we just forbid such matching.  We might later wish to insert an
automatic downcast to the underlying array type, but such a change should
also change matching of domains to ANYELEMENT for consistency.

To ensure that all such logic is rechecked, this patch removes the original
hack of setting a domain's pg_type.typelem field to match its base type;
the typelem will always be zero instead.  In those places where it's really
okay to look through the domain type with no other logic changes, use the
newly added get_base_element_type function in place of get_element_type.
catversion bumped due to change in pg_type contents.

Per bug #5717 from Richard Huxton and subsequent discussion.

Branch
------
master

Details
-------
http://git.postgresql.org/gitweb?p=postgresql.git;a=commitdiff;h=529cb267a6843a6a8190c86b75d091771d99d6a9

Modified Files
--------------
doc/src/sgml/catalogs.sgml           |    5 +-
src/backend/commands/functioncmds.c  |   17 +++++
src/backend/commands/typecmds.c      |   18 ++---
src/backend/parser/parse_coerce.c    |   11 ++--
src/backend/parser/parse_expr.c      |   18 ++---
src/backend/parser/parse_node.c      |   51 ++++++++++----
src/backend/parser/parse_oper.c      |    4 +-
src/backend/parser/parse_target.c    |  127 +++++++++++++++++++++++++---------
src/backend/utils/adt/format_type.c  |   14 ++--
src/backend/utils/adt/ruleutils.c    |    2 +-
src/backend/utils/adt/selfuncs.c     |    2 +-
src/backend/utils/adt/xml.c          |    2 +-
src/backend/utils/cache/lsyscache.c  |   46 ++++++++++++
src/backend/utils/fmgr/fmgr.c        |    4 +-
src/include/catalog/catversion.h     |    2 +-
src/include/catalog/pg_type.h        |    3 +-
src/include/parser/parse_node.h      |    4 +-
src/include/utils/lsyscache.h        |    3 +
src/pl/plpgsql/src/pl_exec.c         |   35 ++++++++--
src/test/regress/expected/domain.out |   99 ++++++++++++++++++++++++++
src/test/regress/sql/domain.sql      |   73 +++++++++++++++++++
21 files changed, 439 insertions(+), 101 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: itagaki@pgfoundry.org (User Itagaki)
Дата:
Сообщение: textsearch-ja - textsearch-ja: Adjust regression test to work on all
Следующее
От: Bruce Momjian
Дата:
Сообщение: pgsql: Mention limited usefulness of .pgpass database field.