]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix handling of COMMENT for domain constraints
authorMichael Paquier <michael@paquier.xyz>
Wed, 12 Jun 2019 02:30:41 +0000 (11:30 +0900)
committerMichael Paquier <michael@paquier.xyz>
Wed, 12 Jun 2019 02:30:41 +0000 (11:30 +0900)
commitfa5f3a4bcca7c222b4ab5a6aba27373aea49a2ec
tree45e5ee9c318c262e3f7db25de49d3fc84745cfda
parent936b5e589e041d04c9dd9ad66883d45caaf0665e
Fix handling of COMMENT for domain constraints

For a non-superuser, changing a comment on a domain constraint was
leading to a cache lookup failure as the code tried to perform the
ownership lookup on the constraint OID itself, thinking that it was a
type, but this check needs to happen on the type the domain constraint
relies on.  As the type a domain constraint relies on can be guessed
directly based on the constraint OID, first fetch its type OID and
perform the ownership on it.

This is broken since 7eca575, which has split the handling of comments
for table constraints and domain constraints, so back-patch down to
9.5.

Reported-by: Clemens Ladisch
Author: Daniel Gustafsson, Michael Paquier
Reviewed-by: Álvaro Herrera
Discussion: https://postgr.es/m/15833-808e11904835d26f@postgresql.org
Backpatch-through: 9.5
src/backend/catalog/objectaddress.c
src/test/regress/input/constraints.source
src/test/regress/output/constraints.source