postgres.git / summary / log / commit / refs

commit    e2ff7d9a83d4b489806281dc6dfce88510b40ad7
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Sat Oct 16 16:23:57 2021 +0000
First released in: 15.0, 10.19, 11.14, 12.9, 13.5, 14.1

    Make pg_dump acquire lock on partitioned tables that are to be dumped.
    
    It was clearly the intent to do so all along, but the original coding
    fat-fingered this by checking the wrong array element.  We fixed it
    in passing in 403a3d91c, but that later got reverted, and we forgot
    to keep this bug fix.
    
    Most of the time this'd be relatively harmless, since once we lock
    any of the partitioned table's leaf partitions, that would suffice
    to prevent major DDL on the partitioned table itself.  However, a
    childless partitioned table would get dumped with no relevant lock
    whatsoever, possibly allowing dump failure or inconsistent output.
    
    Unlike 403a3d91c, there are no versioning concerns, since every server
    version that has partitioned tables will allow you to lock one.
    
    Back-patch to v10 where partitioned tables were introduced.
    
    Discussion: https://postgr.es/m/1018205.1634346327@sss.pgh.pa.us


src/bin/pg_dump/pg_dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index a485fb2d070..5deb347f343 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -7016,7 +7016,7 @@ getTables(Archive *fout, int *numTables) */ if (tblinfo[i].dobj.dump && (tblinfo[i].relkind == RELKIND_RELATION || - tblinfo->relkind == RELKIND_PARTITIONED_TABLE) && + tblinfo[i].relkind == RELKIND_PARTITIONED_TABLE) && (tblinfo[i].dobj.dump & DUMP_COMPONENTS_REQUIRING_LOCK)) { resetPQExpBuffer(query); [parent: b76c1d6e8497]