pgsql: Fix handling of container types in find_composite_type_dependenc

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix handling of container types in find_composite_type_dependenc
Date: 2017-08-09 21:03:51
Message-ID: E1dfY8t-000832-9j@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix handling of container types in find_composite_type_dependencies.

find_composite_type_dependencies correctly found columns that are of
the specified type, and columns that are of arrays of that type, but
not columns that are domains or ranges over the given type, its array
type, etc. The most general way to handle this seems to be to assume
that any type that is directly dependent on the specified type can be
treated as a container type, and processed recursively (allowing us
to handle nested cases such as ranges over domains over arrays ...).
Since a type's array type already has such a dependency, we can drop
the existing special case for the array type.

The very similar logic in get_rels_with_domain was likewise a few
bricks shy of a load, as it supposed that a directly dependent type
could *only* be a sub-domain. This is already wrong for ranges over
domains, and it'll someday be wrong for arrays over domains.

Add test cases illustrating the problems, and back-patch to all
supported branches.

Discussion: https://postgr.es/m/15268.1502309024@sss.pgh.pa.us

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/e2e398473e3c425a8e84a592641acc0db7e22264

Modified Files
--------------
src/backend/commands/tablecmds.c | 49 +++++++++++++++++++++++-------------
src/backend/commands/typecmds.c | 49 +++++++++++++++++++++++-------------
src/test/regress/expected/domain.out | 17 +++++++++++++
src/test/regress/sql/domain.sql | 17 +++++++++++++
4 files changed, 97 insertions(+), 35 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2017-08-10 00:52:57 Re: Re: [COMMITTERS] pgsql: Fix inadequacies in recently added wait events
Previous Message Alvaro Herrera 2017-08-09 19:25:56 Re: Re: [COMMITTERS] pgsql: Fix inadequacies in recently added wait events