Slony-I 2.1.4 Documentation | ||||
---|---|---|---|---|
Prev | Fast Backward | Chapter 8. Schema schemadoc | Fast Forward | Next |
8.102. replicate_partition(p_comment integer, p_idxname text, p_tabname text, p_nspname text, p_tab_id text)
Function Properties
Language: PLPGSQL
Return Type: bigint
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. Note that this function is to be run within an EXECUTE SCRIPT script, so it runs at the right place in the transaction stream on all nodes.declare prec record; prec2 record; v_set_id int4; begin -- 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); end