• Tom Lane's avatar
    Repair incorrect pg_dump labeling for some comments and security labels. · 299990ba
    Tom Lane authored
    We attached no schema label to comments for procedural languages, casts,
    transforms, operator classes, operator families, or text search objects.
    The first three categories of objects don't really have schemas, but
    pg_dump treats them as if they do, and it seems like the TocEntry fields
    for their comments had better match the TocEntry fields for the parent
    objects.  (As an example of a possible hazard, the type names in a CAST
    will be formatted with the assumption of a particular search_path, so
    failing to ensure that this same path is active for the COMMENT ON command
    could lead to an error or to attaching the comment to the wrong cast.)
    In the last six cases, this was a flat-out error --- possibly mine to
    begin with, but it was a long time ago.
    
    The security label for a procedural language was likewise not correctly
    labeled as to schema, and both the comment and security label for a
    procedural language were not correctly labeled as to owner.
    
    In simple cases the restore would accidentally work correctly anyway, since
    these comments and security labels would normally get emitted right after
    the owning object, and so the search path and active user would be correct
    anyhow.  But it could fail in corner cases; for example a schema-selective
    restore would omit comments it should include.
    
    Giuseppe Broccolo noted the oversight, and proposed the correct fix, for
    text search dictionary objects; I found the rest by cross-checking other
    dumpComment() calls.  These oversights are ancient, so back-patch all
    the way.
    
    Discussion: https://postgr.es/m/CAFzmHiWwwzLjzwM4x5ki5s_PDMR6NrkipZkjNnO3B0xEpBgJaA@mail.gmail.com
    299990ba
pg_dump.c 520 KB