Replicating partitioned tables

In Replication Server 15.0, partitioned tables introduced in Adaptive Server® Enterprise 15.0 are replicated in a way that is similar to nonpartitioned tables. The rs_truncate system function in LTL, and the rs_truncate function and function string in Replication Server have been extended to support partitioned tables.

rs_truncate changes in LTL

In LTL, the rs_truncate function has been extended to include partition names, as shown in the following syntax:

distribute command_tags applied [owner=owner_name] 
table.rs_truncate [partition_name, [partition_name]...] yielding

You must assign a partition_name for each partition specified in the truncate table partition command.

rs_truncate function changes in Replication Server

In Replication Server, the rs_truncate function has been extended to accept parameters to support a new truncate table paritition command, shown as follows:

truncate table table_name partition partition_name

When a truncate partition command is issued, the RepAgent sends the following LTL:

applied [owner=owner_name] table_name.rs_truncate, partition_name _yd

rs_truncate function string changes in Replication Server

The partition names are passed as parameters to the rs_truncate function. The rs_truncate function string accepts position-based function-string parameters. The following is a position-based variable that specifies the parameter position in the function, in the LTL command:

?n!param?

A sample function string for rs_truncate with the position-based variable is as follows:

truncate table publishers partition ?1!param?, ?2!param?

Examples

Example 1 To replicate truncate table partition as a delete command, alter the function string in the following way:

alter function string publisher.rs_truncate
for rs_sqlserver_function_class
output language 
'begin transaction
if (?1!param? = '''')	   /* NO parameter */
delete publisher
if (?1!param? = ''A'')
delete publishers where c1 < 1000
if (?1!param? = ''B'')
delete publishers where c1 >= 1000
commit transaction'

Example 2 : To not to truncate table partitions at the replicate server, alter the function string to do nothing if there is a parameter, in the following way:

alter function string publisher.rs_truncate
for rs_sqlserver_function_class
output language 
'if (?1!param? = '''') delete publisher'

Mixed-version issues

For the RepAgent to send an rs_truncate applied subcommand with parameters, the site version must be 15.0 and the LTL version must be 700. If the LTL version is below 700, RepAgent skips the rs_truncate portion of the distribute command.

To replicate the rs_truncate function with a parameter to the replicate Replication Server, the route version must be 1500. If the route version is lower than 1500, the rs_truncate command with the parameter is skipped.