Re: [HACKERS] Dropping partitioned table drops a previously detachedpartition

Поиск
Список
Период
Сортировка
От Amit Langote
Тема Re: [HACKERS] Dropping partitioned table drops a previously detachedpartition
Дата
Msg-id cc836835-b3bc-13ac-337c-ac8589fcb624@lab.ntt.co.jp
обсуждение исходный текст
Ответ на [HACKERS] Dropping partitioned table drops a previously detached partition  (Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>)
Ответы Re: [HACKERS] Dropping partitioned table drops a previously detached partition  (Rahila Syed <rahilasyed90@gmail.com>)
Список pgsql-hackers
Hi Ashutosh,

On 2017/06/12 20:56, Ashutosh Bapat wrote:
> Hi,
> If we detach a partition and drop the corresponding partitioned table,
> it drops the once-partition now-standalone table as well.

Thanks for the report.  Looks like 8b4d582d279d78 missed the bit about
drop_parent_dependency() that you describe in your analysis below.

> The reason for this is as follows
>     An AUTO dependency is recorded between a partitioned table and partition. In
>     case of inheritance we record a NORMAL dependency between parent
> and child. While
>     detaching a partition, we call RemoveInheritance(), which should have taken
>     care of removing this dependency. But it removes the dependencies which are
>     marked as NORMAL. When we changed the dependency for partitioned case from
>     NORMAL to AUTO by updating StoreCatalogInheritance1(), this function was not
>     updated. This caused the dependency to linger behind even after
> detaching the
>     partition, thus causing the now standalone table (which was once a
> partition)
>     to be dropped when the parent partitioned table is dropped. This patch fixes
>     RemoveInheritance() to choose appropriate dependency.
> 
> Attached patch 0001 to fix this.

Looks good to me.  Perhaps, the example in your email could be added as a
test case.

> I see a similar issue-in-baking in case we change the type of
> dependency recorded between a table and the composite type associated
> with using CREATE TABLE ... OF command. 0002 patch addresses the
> potential issue by using a macro while creating and dropping the
> dependency in corresponding functions. There might be more such
> places, but I haven't searched for those.

Might be a good idea too.

Adding this to the open items list.

Thanks,
Amit




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

Предыдущее
От: Ashutosh Bapat
Дата:
Сообщение: Re: [HACKERS] PG10 Partitioned tables and relation_is_updatable()
Следующее
От: Petr Jelinek
Дата:
Сообщение: Re: [HACKERS] pg_subscription_rel entry can be updated concurrently