content_image/696509.jpg
) ENGINE=NDB; 

The following steps are required, in the order shown: 

1. First—and prior  to creating test.t2 —you must insert a row into the mysql.ndb_replication table, as shown here: 

INSERT INTO mysql.ndb_replication VALUES (’test’, ’t2’, 0, NULL, ’NDB$OLD(mycol)’); 

Possible values for the binlog_type  column are shown earlier in this section. The value ’NDB $OLD(mycol)’  should be inserted into the conflict_fn  column. 

2. Create an appropriate exceptions table for test.t2 . The table creation statement shown here includes all required columns; any additional columns must be declared following these columns, and before the definition of the table’s primary key. 

CREATE TABLE test.t2$EX ( server_id INT UNSIGNED, source_server_id INT UNSIGNED, source_epoch BIGINT UNSIGNED, count INT UNSIGNED, a INT UNSIGNED NOT NULL, b CHAR(25) NOT NULL, [ additional_columns ,] PRIMARY KEY(server_id, source_server_id, source_epoch, count) ) ENGINE=NDB; 

We can include additional columns for information about the type, cause, and originating transaction ID for a given conflict. We are also not required to supply matching columns for all primary key columns in the original table. This means you can create the exceptions table like this: 

CREATE TABLE test.t2$EX ( NDB$server_id INT UNSIGNED, NDB$source_server_id INT UNSIGNED, NDB$source_epoch BIGINT UNSIGNED, NDB$count INT UNSIGNED, a INT UNSIGNED NOT NULL, NDB$OP_TYPE ENUM(’WRITE_ROW’,’UPDATE_ROW’, ’DELETE_ROW’, ’REFRESH_ROW’, ’READ_ROW’) NOT NULL, NDB$CFT_CAUSE ENUM(’ROW_DOES_NOT_EXIST’, ’ROW_ALREADY_EXISTS’, ’DATA_IN_CONFLICT’, ’TRANS_IN_CONFLICT’) NOT NULL, NDB$ORIG_TRANSID BIGINT UNSIGNED NOT NULL, [ additional_columns ,] PRIMARY KEY(NDB$server_id, NDB$source_server_id, NDB$source_epoch, NDB$count) ) ENGINE=NDB; 

<img src='content_image/696509.jpg'>

3. Create the table test.t2  as shown previously. 

## Note 

The NDB$  prefix is required for the four required columns since we included at least one of the columns NDB$OP_TYPE , NDB$CFT_CAUSE , or NDB $ORIG_TRANSID  in the table definition. 

These steps must be followed for every table for which you wish to perform conflict resolution using NDB $OLD() . For each such table, there must be a corresponding row in mysql.ndb_replication , and there must be an exceptions table in the same database as the table being replicated. 

