Thread

Commits

  1. pg_dump: label PUBLICATION TABLE ArchiveEntries with an owner.

  1. pg_dump PublicationRelInfo objects need to be marked with owner

    Tom Lane <tgl@sss.pgh.pa.us> — 2021-01-12T17:40:42Z

    Although pg_publication_rel entries don't have an owner per se,
    it's still important for the ArchiveEntry created for one to be
    marked with an appropriate owner, because that is what determines
    which role will be used to run the ALTER PUBLICATION command when
    doing a restore with --use-set-session-authorization.  As the
    code stands, the session's original role will be used to run
    ALTER PUBLICATION.  Admittedly, to have enough privileges to
    create the publication, the original role probably has to be
    superuser, so that generally this'd be moot.  Still, in principle
    it's wrong, and maybe there are edge cases where you'd get a
    failure that you shouldn't.
    
    Accordingly, I propose the attached patch to ensure that the ALTER
    is done as the owner of the publication.  While I was at it I rewrote
    getPublicationTables to do just one query instead of one per table ---
    the existing coding seems like it could be quite inefficient for lots
    of tables.
    
    Upon looking at the code, I notice that the ALTER PUBLICATION ref
    page is lying about the permissions required.  Yes, you do have to
    own the publication, but you *also* have to own the table(s) you
    are adding.  So this raises the question of exactly which user
    we should try to run the command as.  I judged that the publication
    owner is more likely to be the right thing.
    
    Thoughts?
    
    			regards, tom lane