Re: pg_dump --if-exists --clean when drop index that is partition of a partitioned index - Mailing list pgsql-hackers

From Tom Lane
Subject Re: pg_dump --if-exists --clean when drop index that is partition of a partitioned index
Date
Msg-id 1568467.1744727320@sss.pgh.pa.us
Whole thread Raw
In response to Re: pg_dump --if-exists --clean when drop index that is partition of a partitioned index  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: pg_dump --if-exists --clean when drop index that is partition of a partitioned index
List pgsql-hackers
Pavel Stehule <pavel.stehule@gmail.com> writes:
> I have not knowledge, why pg_dump exports DROP INDEX explicitly, although
> it is redundant.

I concur that the proposed patch is probably not the right fix.
It just looks wrong and arbitrary.

My first thought about the right way to fix it was that the
INDEX ATTACH TOC entry should have a dropStmt that is "ALTER ...
DETACH PARTITION", since the way --clean works is to issue the
dropStmts in reverse order.  However, there's no ALTER INDEX
DETACH PARTITION command.  Also, looking at dumpIndexAttach,
there's a comment saying very explicitly not to:

        /*
         * There is no point in creating a drop query as the drop is done by
         * index drop.  (If you think to change this, see also
         * _printTocEntry().)  Although this object doesn't really have
         * ownership as such, set the owner field anyway to ensure that the
         * command is run by the correct role at restore time.
         */

My guess is that that was correct when written and has been falsified
by later changes.  So I think the next thing to do is run down exactly
what broke it and then decide if that change was buggy or if the
comment is just obsolete.  If it's obsolete then we have to figure
out what to do next.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Kirill Reshke
Date:
Subject: Re: speedup COPY TO for partitioned table.
Next
From: Tom Lane
Date:
Subject: Re: use correct variable in error message in _allocAH function (pg_backup_archiver.c)