rs_subcmp

Description

An executable program that compares the data of a replicated table to the primary version of the table. rs_subcmp also performs schema comparison between replicated and primary tables and between replicated and primary databases. These features aid in finding—and optionally reconciling—missing, orphaned, and inconsistent rows and schemas. On UNIX systems, this program is called rs_subcmp. On PC systems, the program is called subcmp.

The rs_subcmp program is located in the bin subdirectory of the Sybase release directory. See the Replication Server installation and configuration guides for your platform for more information.

For rs_subcmp to work, the SYBASE environment variable, and the library path environment variable must be set. If you use rs_subcmp for schema comparison, ensure that rs_subcmp can locate the ddlgen executable file and that the ddlgen can successfully run in your Replication Server environment. See the Usage section for instructions.

rs_subcmp is intended to reconcile Sybase databases only.

Syntax

rs_subcmp [-R | -r] [-v] [-V] [-z[1 | 2]]
 [-f config_file] [-F]
 -S primary_ds [-D primary_db]
 -s replicate_ds [-d replicate_db]
 -t table_name [-T primary_table_name]
 -c select_command [-C primary_select_command]
 -u user [-U primary_user]
 [-p passwd] [-P primary_passwd]
 [-B primary_init_batch]
 [-b replicate_init_batch]
 [-n num_iterations] [-w wait_interval]
 [-e float_precision] [-E real_precision]
 [-k primary_key_column [-k primary_key_column]...]
 [-i identity_column]
 [-l text_image_column_name
 [-l text_image_column_name]...]
 [-L text_image_length_in_kilobytes]
 [-N text_image_column_name
 [-N text_image_column_name]...]
 [-Z language]
 [-o sort_order]
 [-O sort_order]
 [-J rs_subcmp_charset]
 [-j rep_charset]
 [-a replicate_column_name primary_column_name
 [-a replicate_column_name primary_column_name]...]
 [-q unicode_sort_order]
 [-Q unicode_sort_order]
 [-x schema_flag]
 [-X filter_flag]
 [-I interface_file]

Parameters

-R

Reconciles the replicate data with the primary data, making a final verification of data inconsistencies at the primary database. rs_subcmp inserts, deletes, and updates rows at the replicate database so that the replicate data matches the primary data.

-r

Reconciles the replicate data with the primary data, without making a final verification of data inconsistencies at the primary database, as -R does. rs_subcmp inserts, deletes, and updates rows at the replicate database so that the replicate data matches the primary data.

-v

Prints version information.

-V

(Visual) prints the results of the comparison on the display (standard output). If you do not use the -V flag, rs_subcmp does not report differences between rows. Values of text, unitext, or image data are not printed. Instead, rs_subcmp reports whether the inconsistency is in the text, unitext, or image columns or in the columns of other datatypes.

-z

Enables trace. -z1, the default, provides basic trace information, such as comparisons of column headings. -z1 also prints information about numeric precision differences. -z2 provides trace information on comparisons of all rows and commands.

-f config_file

Specifies the name of the configuration file for rs_subcmp.

-F

Displays the format (syntax) to use for the config_file. A configuration file must use the syntax displayed with the -F option, and must contain all required syntax parameters.

-S primary_ds

The name of the data server with the primary data for the subscription.

-D primary_db

The name of the database where the primary data for the subscription is stored.

-s replicate_ds

The name of the data server with the replicate copy of the data.

-d replicate_db

The name of the database with the replicate copy of the data.

-t table_name

The name of the table in the primary and replicate databases with the data to be compared. If the name is different in the databases, use the -T option to specify the name of the table in the primary database. You can include table owner name information here.

-T primary_table_name

The name of the table in the primary database. Use this option when the table name is different in the primary and replicate databases. You can include table owner name information here.

-c select_command

A select command that retrieves the subscription’s data from both the primary and replicate copies of the data. Use -C to specify a different command for the primary data. select commands must order rows based on the primary key.

You can include columns with text, unitext, or image datatypes in the select command, with the following requirements:

  • Columns with text, unitext, or image datatypes cannot be primary key columns.

  • You must place columns with text, unitext, or image datatypes at the end of the select list.

  • By default, the replicate table does not allow null values for text or image columns. You must include the -N flag in the rs_subcmp executable to indicate that a null value is allowed in the text, unitext, or image column of the replicate table.

-C primary_select_command

A select command that retrieves the subscription’s data from the primary copy of the data. Use this option and -c when you need a different select command for the primary and replicate databases. select commands must order rows based on the primary key.

-u user

The login name used to log into the primary and replicate data servers. If you need different login names, use the -U option to specify a different primary data server login name.

-U primary_user

The login name used to log into the primary data server. Use this option and the -u option when different login names are required for the primary and replicate data servers.

-p passwd

The password to use with the user login name and, if supplied, the primary_user login name. If you omit this option, rs_subcmp uses a null password. If you specify a different password for the primary_user login name, specify it with the -P option.

-P primary_passwd

The password to use with the primary_user login name.

-B primary_init_batch

A command batch to be executed when initially connecting to the primary database. The batch can be used for any purpose, such as to set the isolation level. The batch is run after rs_subcmp logs into the primary database.

-b replicate_init_batch

A command batch to be executed when initially connecting to the replicate database. The batch can be used for any purpose, such as to turn off triggers when running rs_subcmp in a warm standby application, or to set the isolation level. The batch is run after rs_subcmp logs into the replicate database.

-n num_iterations

The number of times that rs_subcmp examines the inconsistent rows it finds. The default is 10 iterations. The first iteration may find many inconsistencies due to normal time lag in replication. Additional iterations allow rs_subcmp to distinguish true inconsistencies from the inconsistent rows that are corrected through normal replication activity.

-w wait_interval

The number of seconds rs_subcmp waits before beginning another iteration. The default is 5 seconds.

-e float_precision

Sets the number of decimal places in exponential notation that floating point values are expected to agree. By default, this is set to the maximum precision supported by the platform.

-E real_precision

Sets the number of decimal places in exponential notation that real values are expected to agree. By default, this is set to the maximum precision supported by the platform.

-k primary_key_column

A column name that is part of the primary key for the table. The primary key must be unique and it cannot be a text, unitext, or image column. Use the -k option for each column in the primary key. If the primary and replicate column names are different, the name specified here is the replicate column name.

-i identity_column

The name of the xidentity column in the replicate table.

-l text_image_column_name

Turns off logging of updates to a replicate text, unitext, or image column. By default, text, unitext, or image column updates are logged.

-L text_image_length

Sets the longest value the data server returns for text, unitext, or image columns. The default value is 2048K.

-N text_image_column_name

Indicates that a null value is allowed in the text, unitext, or image column of the replicate table. By default, the replicate table does not allow null values for text, unitext, or image columns.

-Z language

The name of the language in which rs_subcmp generates error and informational messages. If not specified, it uses the language specified in the “default” locale entry for your platform.

-o sort_order

The name of the sort order used in your replication system. rs_subcmp uses this information to compare primary key columns.

-O sort_order

The name of the sort order used in your replication system. rs_subcmp uses this information to compare all columns.

-J rs_subcmp_charset

The name of the character set used by rs_subcmp error and informational messages and in all configuration parameters and command line options. If you do not specify rs_subcmp_charset, it is set to the character set specified in the “default” locale entry for your platform.

-j rep_charset

The name of the character set used by the replicate data server. The rs_subcmp program uses this character set when comparing and reconciling the replicate and primary versions of a table. If you do not specify a rep_charset, it is set to the rs_subcmp_charset character set.

-a replicate_column_name primary_column_name

Specifies the primary column name associated with a replicate column. Use this option if a replicate column name is different from that of the primary column.

NoteWhen you use the -a option, the replicate column name must come before the associated primary column name.

-q unicode_sort_order

Specifies the Unicode sort order rs_subcmp uses to compare Unicode primary key columns.

-Q unicode_sort_order

Specifies the Unicode sort order rs_subcmp uses to compare all Unicode columns.

-x schema_flag

Specifies the rs_subcmp comparison type. The possible values of the schema_flag are:

  • 0 – data comparison. This is the default value.

  • 1 – database schema comparison between two databases.

  • 2 – table schema comparison between two tables.

-X filter

Specifies the schema types and subtypes included or excluded from the comparison. If the value starts with “+”, only the schema types are selected for comparison, and the subschema types are ignored. Otherwise, the schema types and subschema types are both not selected and not used for comparison. For a list of schema types and schema subtypes supported by rs_subcmp, see Table 7-4 and Table 7-5.

-I interface_file

Specifies the interface file location. For more information on the interface file, see the Replication Server configuration guides for your platform.

-g

Creates reconciliation file for inconsistent data.

-h

Performs fast comparison.

-H normalization_option

Indicates how to normalize the data when performing fast comparison. For a list of normalization options supported by rs_subcmp, see Table 7-6.

Examples

Example 1

Starts rs_subcmp using a configuration file called titleauthor.cfg.

rs_subcmp -ftitleauthor.cfg

The configuration file consists of the following:

# titleauthor.cfg - Reconcile
# SYDNEY_DS.pubs2.dbo.titleauthor with
# TOKYO_DS.pubs2.dbo.titleauthor.
#
PDS       = TOKYO_DS
RDS       = SYDNEY_DS
PDB       = pubs2
RDB       = pubs2
PTABLE    = titleauthor
RTABLE    = titleauthor
PSELECT   = select au_id, title_id, au_ord,\ royaltyper
    from titleauthor order by au_id,\ title_id
RSELECT   = select au_id, title_id, au_ord,\ royaltyper
    from titleauthor order by au_id,\ title_id
PUSER     = repuser
RUSER     = repuser
PPWD      = piglet
RPWD      = piglet
KEY       = au_id
KEY       = title_id
RECONCILE = Y
VISUAL    = Y
NUM_TRIES = 3
WAIT      = 10

rs_subcmp compares the primary and replicate tables called titleauthor and generates the following output:

$SYBASE/bin/rs_subcmp -f ttl_au.cmp
INCONSISTENT ROWS:

_________Replicate row________
au_id        title_id  au_ord  royaltyper
-------------------------------------------
672-71-3249  TC7777    1       40
  
__________Primary row_________
au_id        title_id  au_ord  royaltyper
-------------------------------------------
672-71-3249  TC7777    1       50

Example 2

Starts rs_subcmp using a configuration file called subcmp.cfg. Command line flags override the configuration file settings, to reconcile differences in the primary and replicate versions of the authors table, performing a final verification.

rs_subcmp -R -fsubcmp.cfg -STOKYO_DS -Dpubs2 \
 -sSYDNEY_DS -dpubs2 -tauthors

The primary data server and database are TOKYO_DS and pubs2. The replicate data server and database are SYDNEY_DS and pubs2.

Example 3

Compares all schemas between two databases using the config.cfg file:

rs_subcmp -f config.cfg

The configuration file contains:

PDS = PASE
RDS = R2ASE
PDB = pubs2
PTABLE = authors
RTABLE = authors
PUSER = sa
RUSER = sa
PPWD =
RPWD =
SCHEMAFLAG = 1

Example 4

Compares schema between two databases without a configuration file:

rs_subcmp -Spds -srds -Dpdb -drdb -Usa -usa -Psa_pwd
          -psa_pwd -x1

Example 5

Compares schema of two databases excluding index, trigger, and datatype:

rs_subcmp -Spds -srds -Dpdb -drdb -Usa -usa -Psa_pwd
          -psa_pwd -x1 -XitD

Example 6

Compares all table schemas and user schemas:

rs_subcmp -Spds -srds -Dpdb -drdb -Usa -usa -Psa_pwd
          -psa_pwd -x1 -X+TU

Usage


Return codes

The following return codes can be returned by rs_subcmp:

Table 7-2: rs_subcmp return codes

Return code

Meaning

0

The replicated and primary tables are the same.

1

An error occurred while executing rs_subcmp.

2

The replicated and primary tables are different.


Configuration file

You can create a file containing rs_subcmp parameters and specify it on the command line using the -f flag. Each line in the configuration file consists of a parameter name, an equal sign (=), and a value.

The following table lists the parameters that can be used in the rs_subcmp configuration file and the corresponding command line option for each parameter.

Table 7-3: rs_subcmp configuration file parameters

Configuration parameter

Command-line option

Value

PDS

-S

Primary data server name

RDS

-s

Replicate data server name

PDB

-D

Primary database name

RDB

-d

Replicate database name

PTABLE

-T

Primary table name

RTABLE

-t

Replicate table name

PUSER

-U

Primary user name

RUSER

-u

Replicate user name

PPWD

-P

Primary password

RPWD

-p

Replicate password

KEY

-k

Primary key element in replicate table

PINITBATCH

-B

Primary database connection initialization batch. Can span multiple lines if newline characters are preceded by a “\” (backslash). Up to 1024 characters per line and 64K characters total are allowed.

RINITBATCH

-b

Replicate database connection initialization batch. Can span multiple lines if newline characters are preceded by a “\” (backslash). Up to 1024 characters per line and 64K characters total are allowed.

PSELECT

-C

Primary select command. Can span multiple lines if newline characters are preceded by a “\” (backslash). Up to 1024 characters per line and 64K characters total are allowed.

RSELECT

-c

Replicate select command. Can span multiple lines if newline characters are preceded by a “\” (backslash). Up to 1024 characters per line and 64K characters total are allowed.

RECONCILE

-r

Reconcile differences (Y or N)

RECONCILE_CHECK

-R

Reconcile differences with primary verification (Y or N)

TRACE

-z

Enable trace with optional level (optional integer)

FPRECISION

-e

Expected floating point precision (integer—default is platform-dependent)

RPRECISION

-E

Expected real precision (integer—default is platform-dependent)

WAIT

-w

Seconds between comparisons (integer—default is 5 seconds)

NUM_TRIES

-n

Number of comparisons (integer—default is 10 iterations)

VISUAL

-V

Print results (Y or N)

IDENTITY

-i

identity column name in replicate table

TXT_IMG_LEN

-L

The longest value, in kilobytes, the data server returns for text, unitext, or image columns.

NO_LOG

-l

Do not log updates for this replicate text, unitext, or image column

NULLABLE

-N

The text, unitext, or image column in the replicate table accepts null values.

LANGUAGE

-Z

Language of rs_subcmp error and informational messages

SORT_ORDER

-o

Use the specified sort order to compare primary key columns.

SORT_ORDER_ALL_COLS

-O

Use the specified sort order to compare all columns.

SCHARSET

-j

Character set of rs_subcmp

RCHARSET

-J

Character set of the replicate data server

REP_PRI_COLNAME

-a

Replicate-Primary column name pair

UNICODE_SORT_ORDER

-q

The Unicode sort order rs_subcmp uses to compare Unicode primary key columns.

UNICODE_SORT_ORDER_ALL_COLS

-Q

The Unicode sort order rs_subcmp uses to compare all Unicode columns.

SCHEMAFLAG

-x

The rs_subcmp comparison type.

FILTER

-X

The filter used to indicate the schema and schema subtypes included or excluded in the schema comparison. See Table 7-4 and Table 7-5 for a list of schema types and schema subtypes supported by rs_subcmp.

IFILE

-I

The interface file location.

RECONCILE_FILE

-g

Indicates whether to create a reconciliation file or not.

Values:

  • Y – create reconciliation file.

  • N – do not create reconciliation file.

Default: N

FASTCMP

-h

Indicates whether to perform fast comparison or not.

Values:

  • Y – perform fast comparison using compressed data.

  • N – perform normal comparison.

Default: N

HASH_OPTION

-H

Indicates the normalization option used for fast comparison. If this parameter is not included in the configuration file, rs_subcmp normalizes the data using native byte order and character set. See Table 7-6 for a list of the normalization options supported by rs_subcmp.


Requirements for select commands


How rs_subcmp works


Reconciling inconsistencies


Reconciling IDENTITY columns


Reconciling text, unitext, or image datatypes


Using rs_subcmp in international environments


Requirements for character sets and sort orders


Using sort orders


Using Unicode sort orders


Schema types and schema subtypes

Table 7-4 and Table 7-5 list the schema and schema subtypes supported by rs_subcmp.

Table 7-4: Schema types supported by rs_subcmp

Type

Description

A

All aliases in the database.

D

All defaults in the database.

E

All user-defined datatypes in the database.

G

All groups in the database.

R

All rules in the database.

T

All user tables in the database. Includes table elements such as indexes, keys, constraints, and triggers.

U

All users in the database.

V

All views in the database.

P

All procedures in the database.

Table 7-5: Schema subtypes supported by rs_subcmp

Type

Description

c

Constraint

d

Bind default

f

Foreign key

g

Grant

i

Index

m

Procedure mode

p

Primary key

r

Bind rule

t

Trigger


Normalization options for faster comparison

Table 7-6 lists the normalization options for faster comparison supported by rs_subcmp.

Table 7-6: Normalization options supported by rs_subcmp

Normalization option

Description

lsb

Normalizes all byte-order-dependent data to lsb-first (little-endian) byte order.

msb

Normalizes all byte-order-dependent to msb-first (big-endian) byte order.

unicode

Normalizes the character data to Unicode (UTF-16).

unicode_lsb

Normalizes lsb in conjunction with Unicode for platform independence.

unicode_msb

Normalizes msb in conjunction with Unicode for platform independence.