Christopher Browne cbbrowne at ca.afilias.info
Wed Oct 15 09:29:55 PDT 2008
"Knight, Doug" <dknight at wsi.com> writes:
> :o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
>
> All,:p>
>
> I am working on some automation scripts to handle adding and dropping time partitioned tables. I'm looking at Section 20.1 in the documentation,
> and understand the ``traditional approach''. I was wondering if anyone had an example for the method using add_empty_table_to_replication? If I
> understand the steps correctly::p>
>
> :p> 
>
>    1.  Create the new empty partition table on the origin:p>
>    2.  Create the new empty partition table on the target(s):p>
>    3.  Run a shell script invoking slonik with an EXECUTE SCRIPT command, referencing an SQL script containing a call to
>      add_empty_table_to_replication:p>
>
> :p> 
>
> It's the third step I'm unsure about. Do I need to use EXECUTE SCRIPT, or could I just execute the call to the function on each system (origin
> then target)? An example of the shell script using EXECUTE SCRIPT for this specific instance would help a lot.:p>

The function add_empty_table_to_replication() does expect to be run
inside the context of a running EXECUTE SCRIPT request.  Note that the
final two things that it does are thus:

 - calls setAddTable_int(), which adds the table to the set, and adds
   the Slony-I triggers to the table;

 - calls alterTableRestore(), which drops those triggers.

That only works if, subsequently, alterTableForReplication() gets run,
to put the triggers back on.

There is an example of usage of this in the test, "testpartition".

tests/testpartition/gen_ddl_sql.sh is a script that generates the
(rather structured!) contents of a DDL script to be run via EXECUTE
SCRIPT.  

It uses replicate_partition() rather than
add_empty_table_to_replication(), but replicate_partition() is just a
function that calculates the parameters for
add_empty_table_to_replication() based on looking at a table created
using the PostgreSQL inheritance system.
-- 
let name="cbbrowne" and tld="cbbrowne.com" in String.concat "@" [name;tld];;
http://www3.sympatico.ca/cbbrowne/lsf.html
If you're in a vehicle going the speed of light, what happens when you
turn on the headlights?


More information about the Slony1-general mailing list