pgsql: Fix dependency searching for case where column is visited before

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix dependency searching for case where column is visited before
Дата
Msg-id E1XoJUa-0005cE-4G@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix dependency searching for case where column is visited before table.

When the recursive search in dependency.c visits a column and then later
visits the whole table containing the column, it needs to propagate the
drop-context flags for the table to the existing target-object entry for
the column.  Otherwise we might refuse the DROP (if not CASCADE) on the
incorrect grounds that there was no automatic drop pathway to the column.
Remarkably, this has not been reported before, though it's possible at
least when an extension creates both a datatype and a table using that
datatype.

Rather than just marking the column as allowed to be dropped, it might
seem good to skip the DROP COLUMN step altogether, since the later DROP
of the table will surely get the job done.  The problem with that is that
the datatype would then be dropped before the table (since the whole
situation occurred because we visited the datatype, and then recursed to
the dependent column, before visiting the table).  That seems pretty risky,
and the case is rare enough that it doesn't seem worth expending a lot of
effort or risk to make the drops happen in a safe order.  So we just play
dumb and delete the column separately according to the existing drop
ordering rules.

Per report from Petr Jelinek, though this is different from his proposed
patch.

Back-patch to 9.1, where extensions were introduced.  There's currently
no evidence that such cases can arise before 9.1, and in any case we would
also need to back-patch cb5c2ba2d82688d29b5902d86b993a54355cad4d to 9.0
if we wanted to back-patch this.

Branch
------
REL9_4_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/951c2f6faf00a00ab824699c96376d1d8f5acc57

Modified Files
--------------
src/backend/catalog/dependency.c |   74 ++++++++++++++++++++++++++++----------
1 file changed, 56 insertions(+), 18 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix dependency searching for case where column is visited before
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix dependency searching for case where column is visited before