Thread

  1. Re: Proposal: Conflict log history table for Logical Replication

    Dilip Kumar <dilipbalaut@gmail.com> — 2025-12-15T09:25:18Z

    On Mon, Dec 15, 2025 at 2:16 PM shveta malik <shveta.malik@gmail.com> wrote:
    >
    > On Sun, Dec 14, 2025 at 9:20 PM Dilip Kumar <dilipbalaut@gmail.com> wrote:
    > >
    >
    > Thanks for the patch. Few comments:
    
    >
    > 2)
    > postgres=# alter subscription sub1 set (conflict_log_table='');
    > ERROR:  conflict log table name cannot be empty
    > HINT:  Provide a valid table name or omit the parameter.
    >
    > My idea was to allow the above operation to enable users to reset the
    > conflict_log_table when the conflict log history is no longer needed.
    > Is there any other way to reset it, or is this intentionally not
    > supported?
    
    ALTEr SUBSCRIPTION..SET (conflict_log_table=NONE); this is same as how
    other subscription parameters are being reset
    
    > 3)
    > postgres=# alter subscription sub1 set (conflict_log_table=NULL);
    > ALTER SUBSCRIPTION
    > postgres=# alter subscription sub2 set (conflict_log_table=create);
    > ALTER SUBSCRIPTION
    > postgres=# \d
    >          List of relations
    >  Schema |  Name   | Type  | Owner
    > --------+---------+-------+--------
    >  public | create  | table | shveta
    >  public | null    | table | shveta
    >
    >
    > It takes reserved keywords and creates tables with those names. It
    > should be restricted.
    
    I somehow assume table creation will be restricted with these names,
    but since we switch from SPI to internal interface its not true
    anymore, need to see how we can handle this.
    
    > 4)
    > postgres=# SELECT c.relname FROM pg_depend d JOIN pg_class c ON c.oid
    > = d.objid JOIN pg_subscription s ON s.oid = d.refobjid WHERE s.subname
    > = 'sub1';
    >  relname
    > ---------
    >  clt
    >
    > postgres=#  select count(*) from pg_shdepend  where refobjid = (select
    > oid from pg_subscription where subname='sub1');
    >  count
    > -------
    >      0
    >
    > Since dependency between sub and clt is a dependency involving
    > shared-object, shouldn't the entry be in pg_shdepend? Or do we allow
    > such entries in pg_depend as well?
    
    The primary reason for recording in pg_depend is that the
    RemoveRelations() function already includes logic to check for and
    report internal dependencies within pg_depends. Consequently, if we
    were to record the dependency in pg_shdepends, we would likely need to
    modify RemoveRelations() to incorporate handling for pg_shdepends
    dependencies.
    
    However, some might argue that when an object ID (objid) is local and
    the referenced object ID (refobjid) is shared, such as when a table is
    created under a ROLE, establishing a dependency with the owner, the
    dependency is currently recorded in pg_shdepend. In this scenario, the
    dependent object (the local table) can be dropped independently, while
    the referenced object (the shared owner) cannot. However, when aiming
    to record an internal dependency, the dependent object should not be
    droppable without first dropping the referencing object. Therefore, I
    believe the dependency record should be placed in pg_depend, as the
    depender is a local object and will check for dependencies there.
    
    -- 
    Regards,
    Dilip Kumar
    Google