Rules for custom checksum functions
The idschecksum.c file in the $ONEDB_HOME/demo/checksum directory contains code that you can use for your checksum functions. You can replace the checksum generation portion of the code with your custom code.
A checksum function summarizes the data in a replicated row. During consistency checking, the checksum values of corresponding rows on different replication servers are compared to determine whether the rows are consistent.
A checksum function runs recursively through every column in the replicated table to generate a checksum value for a replicated row. A checksum value is generated for the last column in the table. The checksum value is used to calculate the checksum value for the previous column, and so on. The checksum value that is calculated for the first column in the table is based on the accumulated checksum value of all the other columns.
Custom checksum functions must conform to the following rules:
- The first parameter of the function is the data type of a column.
- The second parameter of the function is an integer that is the checksum value of the previous column.
- The function returns an integer.
- The function is a DBA function.
- The function attributes include NOT VARIANT, HANDLESNULLS, and PARALLELIZABLE.
You must register a checksum function for each of the following data types, regardless of whether the data types are used in your replicated tables. All other data types are ignored by checksum functions.
- BLOB
- BYTE
- CLOB
- DATE
- DATETIME YEAR TO FRACTION
- DATETIME YEAR TO MONTH
- DECIMAL
- FLOAT
- INT8
- INTEGER
- LIST
- LVARCHAR (includes all character data types)
- MONEY
- MULTISET
- REAL
- ROW
- SET
- SMALLINT
- TEXT
However, if you do not want to create a checksum value for certain data types, you can provide non-operative function definitions. For example, you might not want to create checksum values for BLOB columns. The following statement registers a checksum function for the BLOB data type that returns the previous checksum value instead of calculating an accumulated checksum value:
CREATE DBA FUNCTION ercheck_checksum(p1 blob, p2 integer)
RETURNS integer;
RETURN p2;
END FUNCTION;