Thread

  1. Replace is_publishable_class() with relispublishable column in pg_class

    Dilip Kumar <dilipbalaut@gmail.com> — 2025-12-16T15:49:21Z

    Hello hackers,
    
    I would like to propose an improvement to the way PostgreSQL
    determines if a relation is eligible for logical replication.
    Currently, this check is performed dynamically via
    is_publishable_class(), which relies on hard-coded OID checks and
    relkind.  As noted in the existing comments atop
    is_publishable_class[1], the long-term solution is to add a boolean
    column to pg_class and depend on that instead of OID checks.
    
    Motivation
    ========
    1) The check is performed frequently in the logical decoding path
    (e.g., in pgoutput_change and pgoutput_truncate). Moving this to a
    cached catalog attribute in pg_class allows for a simple check.
    2) As suggested by Amit Kpila [2], for the upcoming Conflict Log Table
    feature, we need a clean way to exclude these internal conflict log
    tables from publication. A catalog flag allows us to set this property
    at relation creation rather than adding more special cases.
    
    Proposed Changes
    ===============
    The attached patch implements the following:
    1) Catalog Update: Adds relispublishable (bool) to pg_class.
    2) Creation Logic: Input parameter is added to
    heap_create_with_catalog() so that caller can pass whether the
    relation is publishable or not.
    3) Update pgoutput and other relevant places to utilize the new
    pg_class column directly.
    
    [1]
    The best
    * long-term solution may be to add a "relispublishable" bool to pg_class,
    * and depend on that instead of OID checks.
    */
    static bool
    is_publishable_class(Oid relid, Form_pg_class reltuple)
    {
    ..
    }
    
    [2] https://www.postgresql.org/message-id/CAA4eK1K8Aqm%2BjP_EMPF8H_3UJSEExdwDCaphq6%3DunZZMdcmD0A%40mail.gmail.com
    
    -- 
    Regards,
    Dilip Kumar
    Google