]> granicus.if.org Git - postgresql/commit
Disallow changing an inherited column's type if not all parents changed.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 18 Aug 2019 21:11:58 +0000 (17:11 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 18 Aug 2019 21:11:58 +0000 (17:11 -0400)
commit909efc4498a071df1198677bc73366f0e29492ce
tree1fe21d7d014ffe5db3cee151311f9f4a0f8ac059
parentaed967d697de19a78a653926c72604f9b04c3b1e
Disallow changing an inherited column's type if not all parents changed.

If a table inherits from multiple unrelated parents, we must disallow
changing the type of a column inherited from multiple such parents, else
it would be out of step with the other parents.  However, it's possible
for the column to ultimately be inherited from just one common ancestor,
in which case a change starting from that ancestor should still be
allowed.  (I would not be excited about preserving that option, were
it not that we have regression test cases exercising it already ...)

It's slightly annoying that this patch looks different from the logic
with the same end goal in renameatt(), and more annoying that it
requires an extra syscache lookup to make the test.  However, the
recursion logic is quite different in the two functions, and a
back-patched bug fix is no place to be trying to unify them.

Per report from Manuel Rigger.  Back-patch to 9.5.  The bug exists in
9.4 too (and doubtless much further back); but the way the recursion
is done in 9.4 is a good bit different, so that substantial refactoring
would be needed to fix it in 9.4.  I'm disinclined to do that, or risk
introducing new bugs, for a bug that has escaped notice for this long.

Discussion: https://postgr.es/m/CA+u7OA4qogDv9rz1HAb-ADxttXYPqQdUdPY_yd4kCzywNxRQXA@mail.gmail.com
src/backend/commands/tablecmds.c
src/test/regress/expected/inherit.out
src/test/regress/sql/inherit.sql