Christopher B. Browne's Home Page

8.92. replicate_partition(integer, text, text, text, text)

Function Properties

Add a partition table to replication. tab_idxname is optional - if NULL, then we use the primary key. This function looks up replication configuration via the parent table.
      p_tab_id alias for $1;
      p_nspname alias for $2;
      p_tabname alias for $3;
      p_idxname alias for $4;
      p_comment alias for $5;
      prec record;
      prec2 record;
      v_set_id int4;
    -- Look up the parent table; fail if it does not exist
       select c1.oid into prec from pg_catalog.pg_class c1, pg_catalog.pg_class c2, pg_catalog.pg_inherits i, pg_catalog.pg_namespace n where c1.oid = i.inhparent  and c2.oid = i.inhrelid and n.oid = c2.relnamespace and n.nspname = p_nspname and c2.relname = p_tabname;
       if not found then
    	raise exception 'replicate_partition: No parent table found for %.%!', p_nspname, p_tabname;
       end if;
    -- The parent table tells us what replication set to use
       select tab_set into prec2 from sl_table where tab_reloid = prec.oid;
       if not found then
    	raise exception 'replicate_partition: Parent table % for new partition %.% is not replicated!', prec.oid, p_nspname, p_tabname;
       end if;
       v_set_id := prec2.tab_set;
    -- Now, we have all the parameters necessary to run add_empty_table_to_replication...
       return add_empty_table_to_replication(v_set_id, p_tab_id, p_nspname, p_tabname, p_idxname, p_comment);

Contact me at