]> granicus.if.org Git - postgresql/commit
Fix handling of container types in find_composite_type_dependencies.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 9 Aug 2017 21:03:10 +0000 (17:03 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 9 Aug 2017 21:03:10 +0000 (17:03 -0400)
commit06931a9c0e2f59bbc88c6cdfca793fc68508152b
tree85ab96b701e61ccd4c7857412a5c3ef9e561cab5
parent962b26b674d29fa2834afbd760a9229bc42a5876
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
src/backend/commands/tablecmds.c
src/backend/commands/typecmds.c
src/test/regress/expected/domain.out
src/test/regress/sql/domain.sql